:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-brand: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --brand-blue: #1e40af;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-hover: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-border: #93c5fd;
  --primary-text: #ffffff;
  --bold-accent: #0f766e;
  --bold-accent-text: #ffffff;
  --bg-body: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text-strong: #111827;
  --text-base: #1f2937;
  --text-muted: #4b5563;
  --text-light: #6b7280;
  --border-width: 1px;
  --border-color: #cbd5e1;
  --border-color-subtle: #e2e8f0;
  /* Square by design. The radius tokens are kept as names so callers
     keep reading as intent ("this is a panel edge") rather than a
     literal 0 sprinkled through every rule; flipping them here is the
     one place that restores rounding if we ever want it back.
     Genuine circles (status dots, avatars, spinners, switch knobs)
     hard-code 999px/50% and are deliberately unaffected. */
  --radius-xl: 0;
  --radius-lg: 0;
  --radius-md: 0;
  --radius-sm: 0;
  --radius-xs: 0;
  --success: #15803d;
  --success-light: #f0fdf4;
  --success-text: #166534;
  --warning: #b45309;
  --warning-light: #fffbeb;
  --warning-text: #92400e;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-light: #fef2f2;
  --danger-text: #991b1b;
  --info: #1d4ed8;
  --info-light: #eff6ff;
  --info-text: #1e40af;
  /* Status LEDs. Separate from --success/--warning/--danger on purpose:
     those are *fills* tuned to sit behind dark text, so reusing them for
     a 8px solid dot gives a muddy blob in dark mode. These are tuned for
     the opposite job — a small solid shape read against the surface. */
  --indicator-online: #16a34a;
  --indicator-warning: #d97706;
  --indicator-danger: #dc2626;
  --indicator-idle: #94a3b8;
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.2);
  /* Type scale. Four weights, no more. Apple's guidance is to avoid the
     extremes of the weight axis and to build hierarchy from *steps* —
     a UI where every label is Black (900) has no steps left to spend,
     which is exactly what this library used to do. Google Sans Flex
     ships one file per weight, so a small set is also a smaller
     download. */
  /* Type scale. Modelled on Apple's HIG text styles: a small number of
     named steps rather than ad-hoc sizes, 1-2px apart at the small end
     where UI text lives and further apart as headings grow. Before this
     existed the two stylesheets between them used ~30 distinct sizes,
     including 0.62/0.68/0.72/0.78/0.82/0.85/0.9rem, which is what made
     the interface read as slightly-off rather than obviously wrong.
     Pick the nearest step; do not introduce a new one without adding it
     here. */
  --fs-caption-2: 0.6875rem; /* 11px - micro labels, badge text */
  --fs-caption-1: 0.75rem;   /* 12px - captions, dense metadata */
  --fs-footnote: 0.8125rem;  /* 13px - secondary text, hints, ids */
  --fs-subhead: 0.875rem;    /* 14px - default UI text */
  --fs-callout: 0.9375rem;   /* 15px - emphasised UI text */
  --fs-body: 1rem;           /* 16px - prose */
  --fs-headline: 1.125rem;   /* 18px - card and section headings */
  --fs-title-3: 1.25rem;     /* 20px - modal titles */
  --fs-title-2: 1.5rem;      /* 24px */
  --fs-title-1: 1.75rem;     /* 28px */

  /* Leading tightens as type grows, per HIG: headings are set solid-ish,
     body text gets room to breathe. Applying a paragraph line-height to
     a 20px heading is what made modal headers read as loose stacked
     lines rather than one block. */
  --lh-tight: 1.2;   /* titles, single-line labels */
  --lh-snug: 1.3;    /* dense multi-line UI text */
  --lh-normal: 1.5;  /* prose */

  /* Tracking follows the same rule in reverse: negative at display
     sizes, neutral in the middle, positive only for all-caps micro
     labels where the caps need air. */
  --tracking-title: -0.02em;
  --tracking-tight: -0.01em;
  --tracking-normal: 0;
  --tracking-caps: 0.06em;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  /* Micro-label treatment (the small uppercase field captions). Caps
     runs need tracking to stay legible; body text must not inherit it. */
  --tracking-caps: 0.04em;
  --space-container-px: clamp(1rem, 4vw, 2rem);
  --space-xs: clamp(0.25rem, 0.5vw, 0.5rem);
  --space-sm: clamp(0.5rem, 1vw, 0.75rem);
  --space-md: clamp(1rem, 2vw, 1.25rem);
  --space-lg: clamp(1.25rem, 3vw, 1.5rem);
  --space-xl: clamp(1.5rem, 4vw, 2.5rem);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --brand-blue: #1e40af;
  --bg-body: #0b1020;
  --surface: #111827;
  --surface-alt: #1f2937;
  --text-strong: #f9fafb;
  --text-base: #e5e7eb;
  --text-muted: #cbd5e1;
  --text-light: #94a3b8;
  --border-color: #475569;
  --border-color-subtle: #334155;
  --primary: #93c5fd;
  --primary-strong: #bfdbfe;
  --primary-hover: #dbeafe;
  --primary-light: #172554;
  --primary-border: #3b82f6;
  --primary-text: #0f172a;
  --bold-accent: #5eead4;
  --bold-accent-text: #042f2e;
  --success: #15803d;
  --success-light: #052e16;
  --success-text: #86efac;
  --warning: #b45309;
  --warning-light: #422006;
  --warning-text: #fde68a;
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-light: #450a0a;
  --danger-text: #fca5a5;
  --info: #93c5fd;
  --info-light: #172554;
  --info-text: #bfdbfe;
  --indicator-online: #34d399;
  --indicator-warning: #fbbf24;
  --indicator-danger: #f87171;
  --indicator-idle: #64748b;
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.6);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.8);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.9);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  /* Flat, opaque ground. The old two-radial tinted wash read as a
     glass panel floating over nothing and fought every surface drawn
     on top of it. */
  background: var(--bg-body);
  color: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

a {
  color: var(--primary);
}

a.kp-topbar-primary,
a.kp-topbar-primary:hover {
  color: var(--primary-text);
}

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

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

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: var(--fs-title-2);
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
}

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-container {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: var(--space-container-px);
  padding-left: max(var(--space-container-px), env(safe-area-inset-left));
  padding-right: max(var(--space-container-px), env(safe-area-inset-right));
}

.app-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.main-content {
  padding-block: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-lg);
  align-items: stretch;
}

.app-header {
  background-color: var(--brand-blue);
  color: white;
  position: sticky;
  top: 0;
  z-index: 60;
  height: 60px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.app-header .app-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  font-family: var(--font-brand);
  font-weight: var(--fw-bold);
  font-size: clamp(1rem, 2vw, 1.125rem);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: clamp(4px, 1.5vw, 16px);
  align-items: center;
}

.header-actions button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.8;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.header-actions button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.sub-nav {
  position: sticky;
  top: 60px;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border-color-subtle);
  transition: background-color var(--transition-smooth);
}

.sub-nav-content {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 12px var(--space-container-px);
  max-width: 1240px;
  margin-inline: auto;
  scrollbar-width: none;
}

.sub-nav-content::-webkit-scrollbar {
  display: none;
}

.sub-nav-link {
  font-size: var(--fs-footnote);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.sub-nav-link:hover {
  color: var(--primary);
}

.hero-section {
  max-width: 800px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: var(--fw-bold);
  color: var(--text-strong);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
  overflow-wrap: break-word;
}

.hero-subtitle {
  font-size: clamp(0.9375rem, 2vw, 1.25rem);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  max-width: 640px;
}

.content-page {
  padding: 16px 0;
}

.content-page h2 {
  color: var(--text-strong);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-title-2);
}

.content-page h3 {
  color: var(--text-strong);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-headline);
}

.content-page p {
  color: var(--text-base);
  line-height: 1.7;
  margin-bottom: 1em;
}

.ui-sni-highlight {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: var(--fw-semibold);
  border: var(--border-width) solid var(--primary-border);
  user-select: all;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.data-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding: 0;
}

.data-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 7px;
  border-bottom: var(--border-width) solid var(--border-color-subtle);
  font-size: var(--fs-footnote);
}

.data-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ui-card {
  background: var(--surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: var(--transition-smooth);
  position: relative;
  min-width: 0;
}

.ui-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-color-subtle);
}

.card-header {
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
  border-bottom: var(--border-width) solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

.card-meta {
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-medium);
  color: var(--text-light);
  font-family: var(--font-mono);
  background: var(--surface-alt);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

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

.ui-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  border: var(--border-width) solid transparent;
  font-family: inherit;
  outline: none;
  user-select: none;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}

.ui-btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: inherit;
  min-width: 0;
  line-height: 1.2;
}

.ui-btn-spinner {
  position: absolute;
  /* inset:0 + margin:auto dead-centers the fixed-size ring in the
     button; centering this way (rather than top/left + translate)
     leaves `transform` free for the rotate animation. Without it the
     spinner rendered at its static position beside the hidden label —
     off to one side, easy to miss. */
  inset: 0;
  margin: auto;
  width: 1.1em;
  height: 1.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: rotate(0deg);
}

.ui-btn-loading .ui-btn-label {
  visibility: hidden;
}

.ui-btn-loading .ui-btn-spinner {
  opacity: 1;
  animation: kp-btn-spin 700ms linear infinite;
}

@keyframes kp-btn-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.ui-btn-sm {
  padding: 6px 12px;
  font-size: var(--fs-caption-1);
  border-radius: var(--radius-sm);
}

.ui-btn[disabled],
.ui-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.ui-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-light), 0 0 0 4px var(--primary);
}

.ui-btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.ui-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.ui-btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: var(--shadow-xs);
}

.ui-btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.ui-btn-outline:hover {
  border-color: var(--text-light);
  background: var(--surface-alt);
}

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

.ui-btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text-strong);
}

.ui-btn-full {
  width: 100%;
  justify-content: space-between;
}

.action-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--space-md);
}

.action-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.ui-label {
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.ui-input,
.ui-select {
  width: 100%;
  padding: 8px 10px;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--fs-footnote);
  color: var(--text-strong);
  background: var(--surface);
  transition: var(--transition-fast);
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  text-overflow: ellipsis;
}

.ui-input::placeholder {
  color: var(--text-light);
}

.ui-input:focus,
.ui-select:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent);
}

.ui-input:focus-visible,
.ui-select:focus-visible {
  outline: none;
  border-color: var(--primary-border);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 14%, transparent);
}

.ui-input:disabled,
.ui-select:disabled {
  background-color: var(--surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea.ui-input {
  resize: vertical;
  min-height: 100px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.toggle-title {
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  color: var(--text-strong);
  display: block;
}

.toggle-desc {
  font-size: var(--fs-caption-1);
  color: var(--text-muted);
}

.ui-switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  border: var(--border-width) solid var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--surface-alt);
}

.ui-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 16px;
  height: 16px;
  background: var(--text-light);
  border-radius: 50%;
  transform: translateY(-50%);
  transition:
    background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-switch:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
}

.ui-switch:has(input:checked)::after {
  background: white;
  transform: translate(20px, -50%);
}

.ui-switch input,
.ui-checkbox-wrapper input {
  display: none;
}

.ui-checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: var(--fs-subhead);
  font-weight: var(--fw-regular);
  color: var(--text-strong);
  user-select: none;
}

.ui-checkbox {
  width: 20px;
  height: 20px;
  border: var(--border-width) solid var(--border-color);
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  background: var(--surface);
}

.ui-checkbox::after {
  content: "";
  width: 5px;
  height: 10px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg) scale(0);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 2px;
}

.ui-checkbox-wrapper:hover .ui-checkbox {
  border-color: var(--text-light);
}

.ui-checkbox-wrapper input:checked + .ui-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.ui-checkbox-wrapper input:checked + .ui-checkbox::after {
  transform: rotate(45deg) scale(1);
}

.ui-codebox {
  background: var(--surface-alt);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 10px;
  margin-bottom: 10px;
  position: relative;
}

.ui-codebox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: var(--border-width) solid var(--border-color);
  font-family: var(--font-mono);
  font-size: var(--fs-caption-1);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

[data-theme="dark"] .ui-codebox-header {
  background: rgba(255, 255, 255, 0.03);
}

.ui-codebox-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: var(--fs-subhead);
  color: var(--text-strong);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 0;
}

.ui-codebox.titleless .ui-codebox-body {
  padding: 16px 84px 16px 16px;
}

.ui-codebox.titleless > .ui-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0.8;
  z-index: 1;
}

.ui-codebox.titleless > .ui-btn:hover,
.ui-codebox.titleless > .ui-btn:focus-visible {
  opacity: 1;
}

.ui-codebox.oneliner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  flex-direction: row;
  margin: 8px 0;
}

.ui-codebox.oneliner .ui-codebox-body {
  padding: 0;
  flex-grow: 1;
  min-width: 0;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-right: 12px;
  background: transparent;
  border: none;
  font-size: var(--fs-subhead);
  color: var(--text-strong);
}

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

.ui-btn.ui-btn-ghost.ui-btn-sm.is-copied:hover {
  background: transparent;
  color: var(--success);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ui-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-color);
  white-space: nowrap;
  background: var(--surface);
  color: var(--text-base);
  transition: var(--transition-fast);
  cursor: default;
  line-height: 1.25;
}

.ui-pill-sm {
  padding: 2px 6px;
  font-size: var(--fs-caption-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ui-pill.ui-pill-interactive {
  cursor: pointer;
  user-select: none;
}

.ui-pill.ui-pill-interactive:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.ui-pill.active,
.ui-pill.active:hover {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.ui-pill.ui-pill-primary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.ui-pill.ui-pill-success {
  background: var(--success-light);
  color: var(--success-text);
  border-color: color-mix(in srgb, var(--success) 38%, var(--border-color));
}

.ui-pill.ui-pill-warning {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: color-mix(in srgb, var(--warning) 38%, var(--border-color));
}

.ui-pill.ui-pill-danger {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: color-mix(in srgb, var(--danger) 38%, var(--border-color));
}

/* Retained tone name; no longer a translucent "glass" chip — it is the
   neutral tone drawn on a dark brand surface. */
.ui-pill.ui-pill-glass {
  background: var(--surface-alt);
  border-color: var(--border-color-subtle);
  color: var(--text-muted);
}

.ui-pill.ui-pill-static {
  cursor: default;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-color-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-caption-1);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.status-pill-ok {
  border-color: color-mix(in srgb, var(--success) 24%, var(--border-color-subtle));
  background: var(--success-light);
  color: var(--success-text);
}

.status-pill-warning {
  border-color: color-mix(in srgb, var(--warning) 24%, var(--border-color-subtle));
  background: var(--warning-light);
  color: var(--warning-text);
}

.status-pill-danger {
  border-color: color-mix(in srgb, var(--danger) 24%, var(--border-color-subtle));
  background: var(--danger-light);
  color: var(--danger-text);
}

.rich-selector-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
}

.ui-rich-selector {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
  position: relative;
  box-shadow: var(--shadow-xs);
  user-select: none;
  transform: translateZ(0);
}

.ui-rich-selector:hover {
  border-color: var(--text-light);
  background: var(--surface-alt);
  transform: translateY(-1px);
}

.ui-rich-selector input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ui-rich-selector:has(input:focus-visible) {
  border-color: var(--primary-border);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent),
    var(--shadow-xs);
}

.selector-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    border-color var(--transition-fast),
    background-color var(--transition-fast),
    box-shadow var(--transition-fast);
  margin-top: 3px;
}

.selector-dot::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-rich-selector:has(input:checked),
.ui-rich-selector.is-selected {
  border-color: var(--border-color);
  background: color-mix(in srgb, var(--surface) 88%, var(--primary-light));
  box-shadow:
    inset 2px 0 0 color-mix(in srgb, var(--primary) 72%, var(--surface)),
    var(--shadow-xs);
  transform: translateY(-1px);
}

.ui-rich-selector:has(input:checked) .selector-dot,
.ui-rich-selector.is-selected .selector-dot {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 10%, transparent);
}

.ui-rich-selector:has(input:checked) .selector-dot::after,
.ui-rich-selector.is-selected .selector-dot::after {
  transform: scale(1);
}

/* Disabled / "coming soon" selector: greyed, non-interactive, no lift.
   Placed after the checked rules so a checked-but-disabled option (e.g. an
   existing tunnel on a mode we've since parked) still reads as unavailable. */
.ui-rich-selector:has(input:disabled),
.ui-rich-selector.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: var(--surface-alt);
  border-color: var(--border-color);
  box-shadow: none;
}

.ui-rich-selector:has(input:disabled):hover,
.ui-rich-selector.is-disabled:hover {
  border-color: var(--border-color);
  background: var(--surface-alt);
  transform: none;
}

/* "Coming soon" pill, sits at the end of .selector-title's space-between row. */
.selector-badge {
  flex-shrink: 0;
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-medium);
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text-light) 18%, transparent);
  color: var(--text-muted);
  white-space: nowrap;
}

.selector-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.selector-title {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-footnote);
  color: var(--text-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

.selector-desc {
  font-size: var(--fs-caption-1);
  color: var(--text-muted);
  line-height: 1.35;
  font-weight: var(--fw-regular);
  overflow-wrap: break-word;
  word-break: normal;
}

.selector-desc-warning {
  color: var(--warning-text);
}

.selector-icon {
  color: var(--text-light);
  font-size: var(--fs-title-2);
  transition:
    color var(--transition-fast),
    transform var(--transition-fast);
  flex-shrink: 0;
}

.ui-rich-selector:has(input:checked) .selector-icon,
.ui-rich-selector.is-selected .selector-icon {
  color: var(--primary);
  transform: none;
}

@media (prefers-contrast: more) {
  .ui-input:focus-visible,
  .ui-select:focus-visible {
    border-color: var(--primary);
    box-shadow:
      0 0 0 1px var(--surface),
      0 0 0 3px var(--primary);
  }

  .ui-rich-selector:has(input:checked),
  .ui-rich-selector.is-selected {
    border-color: var(--primary);
    box-shadow:
      inset 4px 0 0 var(--primary),
      0 0 0 1px var(--primary);
  }

  .ui-rich-selector:has(input:checked) .selector-dot,
  .ui-rich-selector.is-selected .selector-dot {
    border-width: 2px;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-rich-selector,
  .selector-dot,
  .selector-dot::after,
  .selector-icon {
    transition-duration: 0.01ms;
  }

  .ui-rich-selector,
  .selector-icon {
    transform: none;
  }
}

.ui-alert {
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  font-size: var(--fs-subhead);
  align-items: flex-start;
  border: var(--border-width) solid transparent;
  line-height: 1.5;
  width: 100%;
  min-width: 0;
}

.ui-alert-content {
  flex-grow: 1;
  min-width: 0;
  overflow-wrap: break-word;
  font-weight: var(--fw-regular);
}

.ui-alert-title {
  font-weight: var(--fw-semibold);
  margin-bottom: 2px;
  display: block;
}

.ui-alert-icon {
  font-size: var(--fs-title-3);
  flex-shrink: 0;
}

.ui-alert.info {
  background: var(--info-light);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--info-text);
}

.ui-alert.warning {
  background: var(--warning-light);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warning-text);
}

.ui-alert.danger {
  background: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger-text);
}

.ui-progress-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ui-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-caption-1);
  font-weight: var(--fw-medium);
  flex-wrap: wrap;
  gap: 4px;
}

.ui-progress-track {
  width: 100%;
  height: 8px;
  background-color: var(--border-color-subtle);
  border-radius: var(--radius-xs);
  overflow: hidden;
  transform: translateZ(0);
}

.ui-progress-bar {
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-xs);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-progress-bar.success {
  background-color: var(--success);
}

.ui-progress-bar.warning {
  background-color: var(--warning);
}

.ui-progress-bar.danger {
  background-color: var(--danger);
}

/* kp-status-dot — a solid circle and nothing else. No ring, no halo, no
   border: those were three different implementations across the app and
   all of them read as "the dot is selected/loading". Colour alone never
   carries the state (Apple: don't rely on colour to communicate) — every
   call site pairs the dot with its status text. */
.kp-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--indicator-idle);
}

.kp-dot-online {
  background: var(--indicator-online);
}

.kp-dot-warning {
  background: var(--indicator-warning);
}

.kp-dot-danger {
  background: var(--indicator-danger);
}

/* kp-stat — the label/value pair. One type treatment for every caption +
   figure in the product, so the caption always recedes and the figure
   always leads. Figures are tabular so columns of them line up and a
   live-updating number does not jitter its own width. */
.kp-stat {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.kp-stat-label {
  color: var(--text-light);
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps);
  line-height: 1.2;
  text-transform: uppercase;
}

.kp-stat-value {
  color: var(--text-strong);
  font-size: var(--fs-callout);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kp-stat-hint {
  color: var(--text-muted);
  font-size: var(--fs-caption-1);
  font-weight: var(--fw-regular);
  line-height: 1.35;
}

.kp-stat-lg .kp-stat-value {
  font-size: var(--fs-title-3);
}

/* kp-avatar — initials disc. The one place a circle is the point. */
.kp-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-size: var(--fs-caption-2);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.kp-avatar-lg {
  width: 40px;
  height: 40px;
  font-size: var(--fs-subhead);
}

/* Opt-in tabular figures for numbers rendered outside kp-stat. */
.kp-numeric {
  font-variant-numeric: tabular-nums;
}

.autocomplete-wrapper {
  position: relative;
  width: 100%;
  z-index: 1;
}

.autocomplete-wrapper:focus-within {
  z-index: 90;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: var(--transition-fast);
}

.autocomplete-list.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.autocomplete-item {
  padding: 7px 10px;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-regular);
  color: var(--text-strong);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  overflow: hidden;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
}

.autocomplete-item:hover {
  background: var(--surface-alt);
  color: var(--primary);
}

.autocomplete-item.is-highlighted {
  background: var(--surface-alt);
  color: var(--primary);
}

.item-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.autocomplete-item-desc {
  font-size: var(--fs-caption-1);
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.autocomplete-message {
  padding: 16px;
  color: var(--text-muted);
  font-size: var(--fs-subhead);
  text-align: center;
  user-select: none;
}

.suggestion-icon {
  font-size: var(--fs-headline);
  color: var(--text-light);
  flex-shrink: 0;
}

.ui-custom-select {
  position: relative;
  width: 100%;
  outline: none;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 6px;
}

.select-trigger .select-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-weight: var(--fw-regular);
}

.select-trigger .select-text.placeholder {
  color: var(--text-light);
}

.select-trigger .select-icon {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  font-size: var(--fs-headline);
  flex-shrink: 0;
}

.ui-custom-select.open .select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.ui-custom-select.open .select-trigger .select-icon {
  transform: rotate(180deg);
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
  grid-auto-rows: minmax(130px, auto);
  gap: var(--space-md);
  grid-auto-flow: dense;
}

.bento-item {
  background: var(--surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-smooth);
  cursor: pointer;
  position: relative;
  transform: translateZ(0);
  box-shadow: var(--shadow-xs);
}

.bento-item:hover {
  border-color: var(--border-color-subtle);
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px) translateZ(0);
  z-index: 10;
}

.bento-item.featured {
  grid-column: span 2;
  grid-row: span 2;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
  border-color: var(--primary-border);
}

.bento-item.wide {
  grid-column: span 2;
}

@media (max-width: 480px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }

  .bento-item.featured,
  .bento-item.wide {
    grid-column: span 1;
    grid-row: span 1;
  }
}

.bento-icon {
  color: var(--text-light);
  margin-bottom: 12px;
  font-size: 32px;
  transition: var(--transition-fast);
}

.bento-item:hover .bento-icon {
  color: var(--primary);
  transform: scale(1.05);
}

.bento-item.featured .bento-icon {
  color: var(--primary);
}

.bento-content h3 {
  font-size: var(--fs-callout);
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
  margin-bottom: 4px;
}

.bento-content p {
  font-size: var(--fs-caption-1);
  font-weight: var(--fw-regular);
  color: var(--text-muted);
}

.bento-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.62);
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1),
    background-color 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: grid;
  place-items: center;
  padding: var(--space-container-px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - (2 * var(--space-container-px)));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  border: var(--border-width) solid var(--border-color);
  transform: translateY(8px) scale(0.98) translateZ(0);
  opacity: 0;
  transform-origin: center;
  transition:
    opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  margin: auto;
  overflow: hidden;
}

.modal-panel.wide {
  max-width: 720px;
}

.modal-panel.extra-wide {
  max-width: 960px;
}

.modal-overlay.open .modal-panel {
  transform: translateY(0) scale(1) translateZ(0);
  opacity: 1;
}

.modal-panel.destructive {
  border: var(--border-width) solid var(--danger);
}

.modal-overlay.is-fullscreen {
  background: transparent;
  padding: 0;
  overflow: hidden;
  place-items: stretch;
  z-index: 150;
}

.modal-panel.fullscreen {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
}

.modal-panel.fullscreen .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--surface-alt);
  border-bottom: var(--border-width) solid var(--border-color-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  gap: 12px;
  flex: 0 0 auto;
}

.modal-header__copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.modal-panel.fullscreen .modal-header {
  border-radius: 0;
}

.modal-title {
  margin: 0;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-title-3);
  /* Headings default to body's line-height (1.5), which is tuned for
     paragraph text — on a 20px heading that reads as loose, oversized
     leading above and below the glyphs, stacking with the copy `gap`
     above to make the header read as spaced-out lines instead of one
     block. 1.2 matches the other tight UI labels in this file
     (.ui-btn-label, .ui-btn-spinner). */
  line-height: 1.2;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.modal-header__copy .selector-desc {
  margin: 0;
  /* Tighter than the base .selector-desc (1.35): this is a one- or
     two-line subtitle directly under the title, not a paragraph of
     hint text, and the looser value read as extra space between the
     title and subtitle (and, when a modal has a wrapping subtitle
     link, between its own lines too). */
  line-height: 1.2;
}

.modal-subtitle-link,
.modal-header__copy ::slotted(.modal-subtitle-link) {
  color: var(--primary);
  font-size: var(--fs-caption-1);
  line-height: 1.2;
  font-weight: var(--fw-medium);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: break-word;
}

.modal-subtitle-link:hover,
.modal-header__copy ::slotted(.modal-subtitle-link:hover) {
  color: var(--primary-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-close {
  width: 40px;
  height: 40px;
  background: var(--surface-alt);
  border: var(--border-width) solid var(--border-color);
  color: var(--text-base);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.modal-close:hover {
  background: color-mix(in srgb, var(--surface-alt) 70%, var(--primary-light));
  border-color: var(--primary-border);
  color: var(--text-strong);
}

.modal-body {
  padding: 20px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  color: var(--text-base);
}

.modal-body ::slotted(*) {
  color: var(--text-base);
}

.modal-body ::slotted(.selector-desc) {
  color: var(--text-muted);
}

.modal-footer {
  padding: 16px 20px;
  background: var(--surface-alt);
  border-top: var(--border-width) solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.modal-footer ::slotted(.form-actions) {
  width: 100%;
}

.modal-panel.fullscreen .modal-footer {
  border-radius: 0;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.ui-toast {
  pointer-events: auto;
  background: var(--surface);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: max-content;
  max-width: 100%;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.ui-toast.hiding {
  transform: translateX(120%);
  opacity: 0;
}

.ui-toast.success {
  border-color: rgba(16, 185, 129, 0.45);
}

.ui-toast.error {
  border-color: rgba(239, 68, 68, 0.45);
}

.ui-toast.info {
  border-color: rgba(59, 130, 246, 0.45);
}

.toast-title {
  display: block;
  font-weight: var(--fw-semibold);
  color: var(--text-strong);
}

.toast-desc {
  display: block;
  font-size: var(--fs-subhead);
  color: var(--text-muted);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.kp-page-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color-subtle);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg-body));
}

.kp-page-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px 20px;
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding: 16px var(--space-container-px);
  color: var(--text-muted);
  font-size: var(--fs-footnote);
}

.kp-page-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  min-width: 0;
}

.kp-page-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.kp-page-footer a:hover {
  color: var(--primary);
}

.kp-page-footer small {
  white-space: normal;
}

.app-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: var(--border-width) solid var(--border-color);
  padding: var(--space-xl) 0;
  padding-bottom: max(var(--space-xl), env(safe-area-inset-bottom));
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-subhead);
  user-select: none;
}

.footer-brand strong {
  color: var(--primary);
}

.footer-links {
  display: flex;
  gap: 24px;
  font-size: var(--fs-subhead);
  font-weight: var(--fw-regular);
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.footer-links a:hover {
  color: var(--primary);
}

@media (max-width: 480px) {
  .brand-logo .ui-pill-glass {
    display: none;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
    max-width: none;
  }

  .ui-toast,
  .ui-toast.hiding,
  .ui-toast.show {
    width: 100%;
  }
}

@media (max-width: 720px) {
  /* Default non-fullscreen modals: keep them usable on phones even
     when a caller forgets mobile-fullscreen. Prefer mobile-fullscreen
     for any modal with scrolling content. */
  .modal-overlay {
    padding: 12px;
  }

  .modal-panel,
  .modal-panel.wide,
  .modal-panel.extra-wide {
    max-width: 100%;
    max-height: calc(100dvh - 24px);
  }

.modal-overlay.is-mobile-fullscreen {
  padding: 0;
  overflow: hidden;
  place-items: stretch;
  z-index: 150;
}

  .modal-overlay.is-mobile-fullscreen .modal-panel {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
    opacity: 1;
    transform: translateY(100%) translateZ(0);
    transition:
      transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      opacity 0.2s ease;
    will-change: transform;
  }

  .modal-overlay.open.is-mobile-fullscreen .modal-panel {
    transform: translateY(0) translateZ(0);
  }
}
