/* DeadHook — Precision Telemetry & Signal Control Design System
   Unified tokens, hairline grids, native <dialog> drawers/modals,
   container-query responsive tables, and WCAG AA accessible controls. */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/plus-jakarta-sans-latin-var.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-var.woff2") format("woff2");
}

:root {
  /* Precision Obsidian & Slate Surface Hierarchy */
  --dh-void: #090A0F;
  --dh-well: #0D1017;
  --dh-surface-1: #131722;
  --dh-surface-2: #181D2B;
  --dh-surface-elevated: #1C2233;

  /* 1px Structural Hairlines */
  --dh-hairline: rgba(255, 255, 255, 0.08);
  --dh-hairline-strong: rgba(255, 255, 255, 0.16);

  /* Semantic Signal Accents */
  --dh-cyan: #22D3EE;
  --dh-emerald: #10B981;
  --dh-amber: #F59E0B;
  --dh-crimson: #F43F5E;
  --dh-violet: #A78BFA;

  /* Typography & Ink */
  --dh-text: #F1F5F9;
  --dh-text-secondary: #94A3B8;
  --dh-text-muted: #8496AB;
  --dh-font-display: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --dh-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii & Spacing */
  --dh-radius-sm: 6px;
  --dh-radius-md: 8px;
  --dh-radius-lg: 12px;
  --dh-target-size: 24px;

  /* Strict Z-Index Layering Scale */
  --dh-z-bg: 0;
  --dh-z-sticky: 30;
  --dh-z-nav: 40;
  --dh-z-tooltip: 45;
  --dh-z-toast: 70;
  --dh-z-skip: 100;
}

@media (pointer: coarse) {
  :root {
    --dh-target-size: 44px;
  }
}

/* Base Document & Form-Factor Adaptation */
html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  scroll-padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

body {
  min-block-size: 100dvh;
  background-color: var(--dh-void);
  color: var(--dh-text);
  font-family: var(--dh-font-display);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Subtle Hardware-Inspired Hairline Telemetry Grid */
.dh-grid-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--dh-z-bg);
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(34, 211, 238, 0.08), transparent 65%),
    linear-gradient(to right, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
}

h1, h2, h3 {
  text-wrap: balance;
}

p, li {
  text-wrap: pretty;
}

img, video {
  max-inline-size: 100%;
  block-size: auto;
}

:where(a, code, pre) {
  overflow-wrap: anywhere;
}

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

/* Accessible Skip Link */
.dh-skip {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: var(--dh-z-skip);
  padding: 0.625rem 1rem;
  background: var(--dh-cyan);
  color: #04070B;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--dh-radius-sm);
  transition: top 120ms ease;
}

.dh-skip:focus {
  top: 1rem;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Focus-Visible Ring */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--dh-cyan);
  outline-offset: 2px;
}

/* Visually Hidden Utility */
.dh-sr-only {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* Keep HTML hidden elements hidden even when paired with flex or component display classes */
[hidden]:not([hidden="until-found"]) {
  display: none !important;
}

/* Interactive Control Minimum Hit Targets */
:where(button, select, textarea, input:not([type="checkbox"], [type="radio"]), [role="button"], nav a) {
  min-block-size: var(--dh-target-size);
}

.dh-touch {
  min-block-size: 44px;
  min-inline-size: 44px;
}

/* Core Surface Primitives */
.dh-card,
.dh-obsidian-card,
.dh-hud-frame {
  background: var(--dh-surface-1);
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-lg);
  box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.03) inset;
  min-width: 0;
}

.dh-card--interactive {
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.dh-card--interactive:hover {
  border-color: var(--dh-hairline-strong);
  background: var(--dh-surface-2);
}

.dh-hud-frame-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--dh-hairline);
  background: rgba(13, 16, 23, 0.75);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.dh-hud-frame-title {
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dh-text-secondary);
}

.dh-hud-frame-status {
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--dh-cyan);
}

.dh-hud-frame-body {
  padding: 1rem 1.25rem;
}

/* Brand & Live Indicators */
.dh-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--dh-radius-sm);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: var(--dh-cyan);
  flex-shrink: 0;
}

.dh-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--dh-amber);
  flex-shrink: 0;
}

.dh-live-dot[data-state="live"] {
  background: var(--dh-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.dh-live-dot[data-state="error"] {
  background: var(--dh-crimson);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2);
}

/* Semantic Status Badges & Pills */
.dh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--dh-radius-sm);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.04em;
  border: 1px solid var(--dh-hairline);
  background: var(--dh-surface-2);
  color: var(--dh-text-secondary);
  white-space: nowrap;
}

.dh-badge--cyan {
  color: #67E8F9;
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.1);
}

.dh-badge--emerald {
  color: #6EE7B7;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.dh-badge--amber {
  color: #FCD34D;
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.12);
}

.dh-badge--crimson {
  color: #FDA4AF;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.12);
}

.dh-badge--violet {
  color: #DDD6FE;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.12);
}

.dh-badge--muted {
  color: var(--dh-text-secondary);
  border-color: var(--dh-hairline);
  background: rgba(255, 255, 255, 0.04);
}

/* Buttons */
.dh-btn-primary,
.dh-btn-ghost,
.dh-btn-amber,
.dh-btn-danger,
.dh-btn-crimson {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  min-block-size: 38px;
  border-radius: var(--dh-radius-sm);
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
  text-decoration: none;
  white-space: nowrap;
}

.dh-btn-primary {
  background: var(--dh-cyan);
  color: #05080D;
  border: 1px solid rgba(34, 211, 238, 0.8);
}

.dh-btn-primary:hover:not(:disabled) {
  background: #67E8F9;
}

.dh-btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--dh-text);
  border: 1px solid var(--dh-hairline-strong);
}

.dh-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.28);
}

.dh-btn-amber {
  background: rgba(245, 158, 11, 0.14);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.dh-btn-amber:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.22);
}

.dh-btn-danger,
.dh-btn-crimson {
  background: rgba(244, 63, 94, 0.14);
  color: #FDA4AF;
  border: 1px solid rgba(244, 63, 94, 0.45);
}

.dh-btn-danger:hover:not(:disabled),
.dh-btn-crimson:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.22);
}

.dh-btn-micro {
  min-block-size: 30px;
  padding: 0.25rem 0.6rem;
  font-size: 0.6875rem;
}

:is(.dh-btn-primary, .dh-btn-ghost, .dh-btn-amber, .dh-btn-danger, .dh-btn-crimson):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (pointer: coarse) {
  .dh-btn-primary,
  .dh-btn-ghost,
  .dh-btn-amber,
  .dh-btn-danger,
  .dh-btn-crimson,
  .dh-btn-micro {
    min-block-size: 44px;
  }
}

/* Forms & Accessible Validation (:user-invalid only) */
.dh-label {
  display: block;
  margin-block-end: 0.375rem;
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dh-text-secondary);
}

.dh-input,
.dh-select {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 44px;
  padding: 0.625rem 0.875rem;
  background: var(--dh-well);
  color: var(--dh-text);
  border: 1px solid var(--dh-hairline-strong);
  border-radius: var(--dh-radius-sm);
  font-family: var(--dh-font-display);
  font-size: max(1rem, 0.875rem);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.dh-select {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (pointer: coarse) {
  .dh-input,
  .dh-select {
    min-block-size: 50px;
  }
}

.dh-input::placeholder {
  color: var(--dh-text-muted);
}

.dh-input:focus,
.dh-select:focus {
  border-color: var(--dh-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
  outline: none;
}

.dh-input:user-invalid,
.dh-select:user-invalid {
  border-color: var(--dh-crimson);
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.14);
}

.dh-alert-banner {
  white-space: normal;
  border-radius: var(--dh-radius-sm);
  line-height: 1.45;
}

.dh-badge.hidden,
.dh-alert-banner.hidden {
  display: none;
}

/* KPI Cards */
.dh-kpi {
  position: relative;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.dh-kpi[aria-pressed="true"] {
  border-color: var(--kpi, var(--dh-cyan));
  background: color-mix(in srgb, var(--kpi, var(--dh-cyan)) 10%, var(--dh-surface-1));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--kpi, var(--dh-cyan)) 40%, transparent);
}

/* Code & JSON Viewer */
.dh-code-viewer {
  background: var(--dh-well);
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-md);
  overflow: hidden;
}

.dh-code-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--dh-hairline);
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  color: var(--dh-text-secondary);
}

.dh-code-pre {
  margin: 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: #E2E8F0;
  tab-size: 2;
}

.dh-code-pre[data-wrap="true"] {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Responsive Data Table (@container stacked cards on narrow screens) */
.dh-table-wrapper {
  container-type: inline-size;
  overflow-x: auto;
  max-inline-size: 100%;
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-lg);
  background: var(--dh-surface-1);
}

.dh-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 0.8125rem;
}

.dh-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--dh-well);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--dh-hairline);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dh-text-secondary);
  white-space: nowrap;
}

.dh-table tbody td,
.dh-table tbody th {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--dh-hairline);
  vertical-align: middle;
}

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

.dh-table tbody tr {
  transition: background-color 120ms ease;
}

.dh-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

@container (width < 640px) {
  .dh-table--responsive,
  .dh-table--responsive thead,
  .dh-table--responsive tbody,
  .dh-table--responsive tr,
  .dh-table--responsive th,
  .dh-table--responsive td {
    display: block;
  }

  .dh-table--responsive thead {
    display: none;
  }

  .dh-table--responsive tbody {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .dh-table--responsive tbody tr {
    border: 1px solid var(--dh-hairline);
    border-radius: var(--dh-radius-md);
    background: var(--dh-well);
    padding: 0.5rem 0.75rem;
  }

  .dh-table--responsive tbody td,
  .dh-table--responsive tbody th {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    padding: 0.45rem 0;
    min-width: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .dh-table--responsive tbody th {
    border-bottom: 1px solid var(--dh-hairline);
    padding-bottom: 0.5rem;
    margin-bottom: 0.15rem;
  }

  .dh-table--responsive tbody td:last-child {
    border-bottom: none;
    padding-top: 0.65rem;
  }

  .dh-table--responsive tbody td[data-label]::before {
    content: attr(data-label);
    font-family: var(--dh-font-mono);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dh-text-muted);
    flex-shrink: 0;
  }
}

/* Native <dialog> Modals & Slide-Over Drawers */
dialog {
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-behavior: allow-discrete;
}

dialog[open] {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  dialog {
    transform: translateY(8px) scale(0.985);
  }
  dialog[open] {
    transform: translateY(0) scale(1);
    @starting-style {
      opacity: 0;
      transform: translateY(8px) scale(0.985);
    }
  }
  dialog.dh-drawer {
    transform: translateY(16px);
  }
  dialog.dh-drawer[open] {
    transform: translateY(0);
    @starting-style {
      opacity: 0;
      transform: translateY(16px);
    }
  }
}

@media (min-width: 768px) and (prefers-reduced-motion: no-preference) {
  dialog.dh-drawer {
    transform: translateX(24px);
  }
  dialog.dh-drawer[open] {
    transform: translateX(0);
    @starting-style {
      opacity: 0;
      transform: translateX(24px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog {
    transition-duration: 90ms;
  }
}

dialog:modal {
  overscroll-behavior: contain;
  color: var(--dh-text);
  background: transparent;
  border: none;
  padding: 0;
  max-width: 100vw;
  max-height: 100dvh;
}

dialog::backdrop {
  background: rgba(5, 7, 12, 0);
  backdrop-filter: blur(6px);
  overflow: hidden;
  overscroll-behavior: contain;
  transition-property: background-color, display, overlay;
  transition-duration: 180ms;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

dialog[open]::backdrop {
  background: rgba(5, 7, 12, 0.78);
  @starting-style {
    background: rgba(5, 7, 12, 0);
  }
}

.dh-modal-panel,
dialog.dh-dialog {
  width: min(94vw, 34rem);
  margin: auto;
  background: var(--dh-surface-1);
  border: 1px solid var(--dh-hairline-strong);
  border-radius: var(--dh-radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  overflow-x: hidden;
}

dialog.dh-dialog {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  color: var(--dh-text);
}

dialog.dh-dialog--wide {
  width: min(94vw, 52rem);
}

/* Slide-Over Inspector Drawer: bottom sheet on mobile, right-hand inspector on desktop */
dialog.dh-drawer {
  margin: 0;
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-height: 90dvh;
  background: var(--dh-surface-1);
  border-top: 1px solid var(--dh-hairline-strong);
  border-top-left-radius: var(--dh-radius-lg);
  border-top-right-radius: var(--dh-radius-lg);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.7);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

dialog.dh-drawer[open] {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  dialog.dh-drawer {
    inset: 0 0 0 auto;
    width: min(92vw, 40rem);
    height: 100dvh;
    max-height: 100dvh;
    border-top: none;
    border-left: 1px solid var(--dh-hairline-strong);
    border-radius: 0;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.7);
  }
}

/* Command Palette Dialog */
dialog.dh-cmd-palette {
  width: min(94vw, 38rem);
  margin: min(14vh, 6rem) auto auto;
  background: var(--dh-surface-1);
  border: 1px solid var(--dh-hairline-strong);
  border-radius: var(--dh-radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

/* Help Tooltips */
.dh-help-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-block-size: 24px;
  min-inline-size: 24px;
  border-radius: 9999px;
  border: 1px solid var(--dh-hairline-strong);
  background: var(--dh-surface-2);
  color: var(--dh-text-secondary);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

.dh-help-btn > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  text-decoration: none;
  color: inherit;
}

@media (pointer: coarse) {
  .dh-help-btn > a::after {
    content: "";
    position: absolute;
    inset: -10px;
  }
}

.dh-help-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(calc(-50% + var(--dh-tip-shift, 0px)));
  width: min(240px, calc(100vw - 2rem));
  padding: 0.625rem 0.75rem;
  background: var(--dh-surface-elevated);
  border: 1px solid var(--dh-hairline-strong);
  border-radius: var(--dh-radius-sm);
  color: var(--dh-text);
  font-family: var(--dh-font-display);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
  text-align: left;
  z-index: var(--dh-z-tooltip);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.dh-help-btn:not([data-dismissed]):hover .dh-help-tip,
.dh-help-btn:not([data-dismissed]):focus-within .dh-help-tip {
  display: block;
}

/* Global Toast */
.dh-hud-toast {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--dh-z-toast);
  max-width: min(92vw, 24rem);
  padding: 0.75rem 1rem;
  border-radius: var(--dh-radius-md);
  border: 1px solid var(--dh-hairline-strong);
  background: var(--dh-surface-elevated);
  color: var(--dh-text);
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  transition: transform 200ms ease, opacity 200ms ease;
}

@media (min-width: 1024px) {
  .dh-hud-toast {
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }
}

/* Row Arrival Animation */
@keyframes dhRowFlash {
  0% { background-color: rgba(34, 211, 238, 0.16); }
  100% { background-color: transparent; }
}

.dh-row-arrival {
  animation: dhRowFlash 900ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .dh-row-arrival {
    animation-duration: 180ms;
  }
}

/* Mobile Bottom Command Bar */
.dh-mobile-dock {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: var(--dh-z-nav);
  background: rgba(9, 10, 15, 0.97);
  border-top: 1px solid var(--dh-hairline);
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Reduced Motion Baseline (scroll & error shake dampening; continuous motion gated via no-preference) */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Auth Error Shake */
@keyframes dhShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: no-preference) {
  .dh-shake {
    animation: dhShake 200ms ease-in-out;
  }
}

/* Provider Tags & KV Inspector Rows */
.dh-provider-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.175rem 0.5rem;
  border-radius: var(--dh-radius-sm);
  border: 1px solid var(--dh-hairline);
  background: var(--dh-well);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--dh-text);
}

.dh-provider-icon {
  display: inline-block;
  flex-shrink: 0;
}

.dh-provider-code {
  letter-spacing: 0.04em;
}

.dh-provider-tag--stripe { color: #C4B5FD; border-color: rgba(139, 92, 246, 0.35); }
.dh-provider-tag--shopify { color: #6EE7B7; border-color: rgba(16, 185, 129, 0.35); }
.dh-provider-tag--github { color: #E2E8F0; border-color: rgba(226, 232, 240, 0.25); }
.dh-provider-tag--twilio { color: #FDA4AF; border-color: rgba(244, 63, 94, 0.35); }
.dh-provider-tag--generic { color: #67E8F9; border-color: rgba(34, 211, 238, 0.3); }

.dh-kv-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.dh-kv-row td,
.dh-kv-row th {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.dh-kv-row:last-child td,
.dh-kv-row:last-child th {
  border-bottom: none;
}

.dh-kv-row th.dh-kv-key {
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dh-text-secondary);
  width: 1%;
  white-space: nowrap;
  text-align: left;
}

.dh-kv-val-cell {
  min-width: 0;
}

@media (max-width: 639px) {
  .dh-kv-row td,
  .dh-kv-row th {
    padding: 0.5rem 0.625rem;
  }
}

.dh-kv-val-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dh-kv-value,
.dh-secret-value {
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  color: var(--dh-text);
  word-break: break-all;
}

.dh-secret-value[data-secret-state="masked"] {
  color: var(--dh-text-muted);
}

.dh-kv-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.dh-session-banner {
  margin-bottom: 1.5rem;
  border-color: rgba(245, 158, 11, 0.45);
}

/* Command Palette & Drawer Helpers */
.dh-cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--dh-radius-sm);
  text-align: left;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  color: var(--dh-text);
  transition: background-color 100ms ease;
}

.dh-cmd-item:hover,
.dh-cmd-item:focus-visible,
.dh-cmd-item[aria-selected="true"] {
  background: rgba(34, 211, 238, 0.12);
  color: #67E8F9;
}

/* Structural Frame Helpers, Subnav, Collapsibles & Checkboxes (endpoints.html & guide.html) */
.dh-crosshairs {
  position: relative;
  border-color: color-mix(in srgb, var(--dh-card-accent, var(--dh-hairline)) 32%, rgba(255, 255, 255, 0.08));
}

.dh-card-static:hover {
  border-color: var(--dh-hairline);
  background: var(--dh-surface-1);
}

.dh-subnav {
  position: sticky;
  top: calc(3.5rem + env(safe-area-inset-top, 0px));
  z-index: var(--dh-z-sticky);
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(13, 16, 23, 0.97);
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-md);
}

@media (min-width: 1024px) {
  .dh-subnav {
    top: 0.75rem;
  }
}

.dh-subnav-link {
  display: inline-flex;
  align-items: center;
  min-block-size: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: var(--dh-radius-sm);
  border: 1px solid transparent;
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--dh-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.dh-subnav-link:hover,
.dh-subnav-link:focus-visible {
  color: var(--dh-cyan);
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
}

@media (pointer: coarse) {
  .dh-subnav-link {
    min-block-size: 44px;
  }
}

.dh-collapse {
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-md);
  background: var(--dh-well);
}

.dh-collapse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-block-size: 44px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dh-text);
  user-select: none;
}

.dh-collapse-head::-webkit-details-marker {
  display: none;
}

.dh-collapse-body {
  padding: 1rem;
  border-top: 1px solid var(--dh-hairline);
}

.dh-check-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.625rem;
  min-block-size: 44px;
  font-size: 0.8125rem;
  color: var(--dh-text-secondary);
  cursor: pointer;
}

.dh-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--dh-cyan);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.dh-input--compact {
  min-block-size: 36px;
  padding: 0.375rem 0.625rem;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
}

@media (pointer: coarse) {
  .dh-input--compact {
    min-block-size: 44px;
  }
}

.dh-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 28px;
  min-inline-size: 28px;
  text-decoration: none;
}

.dh-brand-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--dh-cyan);
  flex-shrink: 0;
}

/* Event Detail Inspector (event_detail.html) */
.dh-mode-tab {
  display: inline-flex;
  align-items: center;
  min-block-size: 30px;
  padding: 0.25rem 0.6rem;
  border-radius: var(--dh-radius-sm);
  border: 1px solid var(--dh-hairline);
  background: var(--dh-well);
  color: var(--dh-text-secondary);
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.dh-mode-tab[aria-pressed="true"] {
  color: #67E8F9;
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.12);
}

.dh-mode-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (pointer: coarse) {
  .dh-mode-tab {
    min-block-size: 44px;
  }
}

.dh-code-well {
  overflow-x: auto;
  max-height: 28rem;
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-sm);
  background: #05070B;
}

.dh-code-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--dh-font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
}

.dh-line-num {
  width: 3rem;
  min-width: 2.5rem;
  padding: 0.125rem 0.625rem;
  text-align: right;
  color: var(--dh-text-muted);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
  vertical-align: top;
}

.dh-line-code {
  padding: 0.125rem 0.75rem;
  color: #E2E8F0;
  white-space: pre-wrap;
  word-break: break-word;
}

.dh-code-table--nowrap .dh-line-code {
  white-space: pre;
  word-break: normal;
}

.dh-tok-key { color: #67E8F9; }
.dh-tok-str { color: #6EE7B7; }
.dh-tok-num { color: #FCD34D; }
.dh-tok-bool { color: #DDD6FE; }
.dh-tok-null { color: var(--dh-text-muted); }

.dh-diff-del { background: rgba(244, 63, 94, 0.12); }
.dh-diff-add { background: rgba(34, 211, 238, 0.12); }
.dh-diff-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .dh-diff-split {
    grid-template-columns: 1fr 1fr;
  }
}

.dh-attempt-rail {
  position: relative;
}

.dh-attempt-item {
  position: relative;
  border-left: 2px solid var(--dh-card-accent, var(--dh-cyan));
}

.dh-attempt-marker {
  position: absolute;
  left: -5px;
  top: 1.15rem;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
}

.dh-latency-track {
  width: 4.5rem;
  height: 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dh-latency-bar {
  height: 100%;
  border-radius: inherit;
}

.dh-fanout-rail {
  min-width: 0;
}

.dh-fanout-node {
  border-left: 2px solid var(--dh-card-accent, var(--dh-cyan));
  transition: border-color 140ms ease, background-color 140ms ease;
}

.dh-fanout-node:hover {
  background: var(--dh-surface-2);
}

/* Tabs Selected Shape Indicator (WCAG 1.4.1 — shape + color) */
[role="tab"] {
  position: relative;
}

[role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  border-block-end: 2px solid var(--dh-cyan);
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  pointer-events: none;
}

/* Landing Page Telemetry Animations (Compositor-Only + Reduced-Motion Safe) */
.dh-signal-conduit {
  position: relative;
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-md);
  background: rgba(9, 10, 15, 0.85);
  padding: 0.625rem 0.75rem;
  overflow: hidden;
}

.dh-signal-svg {
  display: block;
  width: 100%;
  height: 22px;
}

.dh-signal-track {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 2;
  fill: none;
}

.dh-signal-packet {
  stroke: var(--dh-cyan);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 18 38;
  fill: none;
  opacity: 0.85;
}

.dh-signal-conduit[data-flow-state="error"] .dh-signal-packet {
  stroke: var(--dh-crimson);
}

.dh-signal-conduit[data-flow-state="backoff"] .dh-signal-packet {
  stroke: var(--dh-amber);
}

.dh-signal-conduit[data-flow-state="replayed"] .dh-signal-packet {
  stroke: var(--dh-emerald);
}

.dh-signal-node {
  fill: var(--dh-surface-2);
  stroke: var(--dh-cyan);
  stroke-width: 2;
  transition: stroke 160ms ease, fill 160ms ease;
}

.dh-signal-conduit[data-flow-state="live"] .dh-signal-node--ingress,
.dh-signal-conduit[data-flow-state="live"] .dh-signal-node--state {
  stroke: var(--dh-cyan);
}

.dh-signal-conduit[data-flow-state="error"] .dh-signal-node--target {
  stroke: var(--dh-crimson);
  fill: rgba(244, 63, 94, 0.3);
}

.dh-signal-conduit[data-flow-state="backoff"] .dh-signal-node--buffer {
  stroke: var(--dh-amber);
  fill: rgba(245, 158, 11, 0.3);
}

.dh-signal-conduit[data-flow-state="replayed"] .dh-signal-node {
  stroke: var(--dh-emerald);
  fill: rgba(16, 185, 129, 0.28);
}

@keyframes dhPacketFlow {
  from { transform: translateX(-56px); }
  to { transform: translateX(0); }
}

@keyframes dhNodePulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

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

.dh-step-node {
  transition: border-color 180ms ease, background-color 180ms ease, opacity 180ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dh-step-node--error {
  border-color: rgba(244, 63, 94, 0.55);
  background: rgba(244, 63, 94, 0.08);
}

.dh-step-node--warn {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.08);
}

.dh-step-node--success {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.08);
}

.dh-sim-log {
  background: rgba(9, 10, 15, 0.85);
  border: 1px solid var(--dh-hairline);
  border-radius: var(--dh-radius-sm);
  padding: 0.5rem 0.75rem;
  /* Mobile CLS guard: rows animate in, so reserve the approximate height
     of two rows to stop the footer from jumping when the log populates. */
  min-block-size: 3.25rem;
}

.dh-sim-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--dh-font-mono);
  font-size: 0.6875rem;
  padding-block: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dh-sim-log-row:last-child {
  border-bottom: none;
}

.dh-pipe-rail {
  position: relative;
  height: 4px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dh-pipe-progress {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--dh-pipe-ratio, 0.2));
  background: linear-gradient(90deg, var(--dh-cyan), var(--dh-emerald));
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: no-preference) {
  .dh-signal-packet {
    animation: dhPacketFlow 1.4s linear infinite;
  }

  .dh-conduit-paused .dh-signal-packet {
    animation-play-state: paused;
  }

  .dh-signal-conduit[data-flow-state="error"] .dh-signal-packet {
    animation-duration: 2.2s;
  }

  .dh-signal-conduit[data-flow-state="replayed"] .dh-signal-packet {
    animation-duration: 0.9s;
  }

  .dh-step-node--pulse {
    animation: dhNodePulse 360ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .dh-sim-log-row {
    animation: dhLogSlideIn 190ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--dh-stagger, 0ms);
  }

  .dh-pipe-detail-enter {
    animation: dhLogSlideIn 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .dh-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition:
      opacity 260ms cubic-bezier(0.22, 1, 0.36, 1) var(--dh-delay, 0ms),
      transform 260ms cubic-bezier(0.22, 1, 0.36, 1) var(--dh-delay, 0ms);
  }

  .dh-reveal.dh-reveal--visible {
    opacity: 1;
    transform: translateY(0);
  }

  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes dhTelemetryEnter {
      from {
        opacity: 0;
        transform: translateY(14px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .dh-reveal {
      opacity: 1;
      transform: none;
      transition: none;
      animation: dhTelemetryEnter 1ms cubic-bezier(0.22, 1, 0.36, 1) both;
      animation-timeline: view();
      animation-range: entry 0% entry 28%;
    }
  }
}

/* Landing Simulator Typewriter & Cross-Device Locator Indicator */
.dh-sim-payload {
  min-block-size: 11.5rem;
}

.dh-type-caret::after {
  content: "▋";
  margin-inline-start: 2px;
  color: var(--dh-cyan);
  font-size: 0.75em;
  vertical-align: baseline;
}

.dh-sim-spotlight {
  border-color: var(--dh-cyan) !important;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35), 0 0 28px rgba(34, 211, 238, 0.18);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.dh-locate-arrow {
  display: inline-block;
  transition: transform 160ms ease;
  color: var(--dh-cyan);
  font-weight: 700;
}

.dh-locate-arrow--desktop {
  display: none;
}

.dh-locate-arrow--mobile {
  display: inline-block;
}

@media (min-width: 1024px) {
  .dh-locate-arrow--desktop {
    display: inline-block;
  }
  .dh-locate-arrow--mobile {
    display: none;
  }
}

@keyframes dhCaretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes dhSimBeacon {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55), 0 0 0 rgba(34, 211, 238, 0);
  }
  45% {
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.38), 0 0 36px rgba(34, 211, 238, 0.28);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35), 0 0 28px rgba(34, 211, 238, 0.18);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .dh-type-caret::after {
    animation: dhCaretBlink 750ms steps(1, end) infinite;
  }

  .dh-sim-spotlight {
    animation: dhSimBeacon 650ms cubic-bezier(0.22, 1, 0.36, 1) 1;
  }

  :where(a, button):hover .dh-locate-arrow--desktop,
  :where(a, button):focus-visible .dh-locate-arrow--desktop {
    transform: translateX(3px);
  }

  :where(a, button):hover .dh-locate-arrow--mobile,
  :where(a, button):focus-visible .dh-locate-arrow--mobile {
    transform: translateY(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dh-reveal {
    opacity: 1;
    transform: none;
  }
  .dh-pipe-progress {
    transition-duration: 0.01ms;
  }
  .dh-locate-arrow {
    transition: none;
  }
}
