
:root {
  --bg: #05080f;
  --surface: #0a1020;
  --card: #111a33;
  --card-hi: #16213f;
  --border: #1b2747;
  --border-hi: #2a3a66;
  --text: #f7f8fb;
  --muted: rgba(247,248,251,0.62);
  --muted-soft: rgba(247,248,251,0.40);
  --accent: #1ea7ff;
  --accent-hi: #4fc3ff;
  --accent-subtle: rgba(30,167,255,0.12);
  --x: #ef4444; --y: #22c55e; --z: #1ea7ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* The HTML `hidden` attribute must always win over our explicit display rules. */
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Inter Tight', 'Inter', sans-serif; letter-spacing: -0.015em; }

.page-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 28px 24px;
}
.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.brand h1 { font-size: 32px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.brand h1 .tighter { color: var(--accent-hi); letter-spacing: 0.04em; font-weight: 500; }
.brand .eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin-bottom: 6px;
}
.lede { color: var(--muted); max-width: 720px; font-size: 15.5px; line-height: 1.6; }

.filter-bar {
  max-width: 1180px;
  margin: 12px auto 22px;
  padding: 12px 28px;
  position: sticky; top: 0;
  background: linear-gradient(to bottom, var(--bg) 78%, transparent);
  z-index: 5;
}
.filter-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 500 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: background-color 200ms, border-color 200ms, color 200ms;
}
.filter-toggle:hover,
.filter-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent-hi);
  background: var(--accent-subtle);
}
.filter-toggle svg { flex-shrink: 0; }
.filter-toggle-label { letter-spacing: 0.01em; }
.filter-toggle-count { color: var(--muted-soft); margin-left: 2px; }
.filter-toggle-caret {
  transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}
.filter-toggle[aria-expanded="true"] .filter-toggle-caret { transform: rotate(180deg); }

.filter-list {
  position: absolute;
  top: calc(100% - 4px);
  left: 28px;
  display: flex; flex-wrap: wrap; gap: 6px;
  max-width: 360px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  z-index: 6;
  animation: filter-pop-in 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes filter-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}
.chip {
  padding: 7px 13px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 500 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: background-color 180ms, border-color 180ms, color 180ms;
}
.chip:hover { color: var(--text); border-color: var(--border-hi); }
.chip.active {
  background: var(--accent-subtle);
  color: var(--accent-hi);
  border-color: var(--accent);
}

.grid {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 80px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px;
}
.card-head h3 {
  font-size: 17px; font-weight: 600;
  margin: 0;
}
.card-id {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted-soft);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.family-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag-gizmo     { color: #fca5a5; border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.10); }
.tag-orbit     { color: #93c5fd; border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.10); }
.tag-lidar     { color: #86efac; border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.10); }
.tag-technical { color: #fcd34d; border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.10); }
.tag-floorplan { color: #c4b5fd; border-color: rgba(167,139,250,0.4); background: rgba(167,139,250,0.10); }
.tag-signature { color: #f0abfc; border-color: rgba(232,121,249,0.4); background: rgba(232,121,249,0.10); }
.tag-drone     { color: #67e8f9; border-color: rgba(34,211,238,0.4); background: rgba(34,211,238,0.10); }
.tag-phase4    { color: #7dd3fc; border-color: rgba(56,189,248,0.5);  background: rgba(56,189,248,0.10); font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.06em; }
.tag-phase5    { color: #fdba74; border-color: rgba(251,146,60,0.5);  background: rgba(251,146,60,0.10); font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.06em; }

.card-previews {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.preview {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  overflow: hidden;
}
.preview svg { width: 86%; height: 86%; }
.preview-dark { background: #0a1020; }
.preview-light { background: #fff; }

.card-blurb {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
}

.card-lockup {
  display: grid; grid-template-columns: 1fr; gap: 6px;
  margin-top: 4px;
}
.lockup {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: grid; place-items: start center;
  overflow: hidden;
}
.lockup svg { width: 100%; max-height: 56px; }
.lockup-dark { background: #0a1020; }
.lockup-light { background: #fff; }

.card-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.action {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.action:hover { color: var(--accent-hi); border-color: var(--accent); background: var(--accent-subtle); }

.page-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 28px 60px;
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted-soft);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
.page-footer .mono { font-family: 'JetBrains Mono', monospace; }

/* ==== Mobile / tablet adaptations ==== */
@media (max-width: 720px) {
  body { font-size: 16px; }                  /* iOS won't auto-zoom text inputs at ≥16px */
  .page-header { padding: 22px 16px 10px; }
  .brand { gap: 12px; margin-bottom: 14px; }
  .brand h1 { font-size: 22px; }
  .brand .eyebrow { font-size: 10.5px; margin-bottom: 4px; }
  .lede { font-size: 14.5px; line-height: 1.55; }
  .filters {
    padding: 10px 16px;
    gap: 6px;
    /* Allow horizontal scroll if too many chips */
    flex-wrap: wrap;
  }
  .chip {
    padding: 9px 13px;                       /* taller tap target */
    font-size: 13px;
    min-height: 38px;
  }
  .grid {
    padding: 0 16px 60px;
    gap: 14px;
    grid-template-columns: 1fr;              /* one column < 720px so cards (and previews) are roomy */
  }
  .card { padding: 16px; gap: 14px; }
  .card-head h3 { font-size: 16.5px; }
  .card-actions { gap: 6px; padding-top: 12px; }
  .action {
    font-size: 11.5px;
    padding: 7px 11px;                       /* meets ~32 px tap-target floor */
    min-height: 32px;
  }
  /* Bigger preview tiles inside the card now that we're single-column */
  .preview svg { width: 78%; height: 78%; }
  .lockup svg  { max-height: 64px; }
}

/* ==== Narrow phones (<420px) — nudge font sizes & padding ==== */
@media (max-width: 420px) {
  .page-header { padding: 18px 14px 8px; }
  .brand h1 { font-size: 20px; }
  .lede { font-size: 13.5px; }
  .filters { padding: 8px 14px; }
  .grid { padding: 0 14px 60px; }
  .card { padding: 14px; }
  .card-head h3 { font-size: 16px; }
}

/* ============================================================
   Card hover affordance + click-to-open hint
   ============================================================ */
.card { cursor: pointer; transition: transform .2s, border-color .2s; }
.card:hover { transform: translateY(-2px); border-color: var(--border-hi); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-cta-hint {
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  transition: color .2s;
}
.card:hover .card-cta-hint { color: var(--accent-hi); }
.card:hover .cta-arrow { transform: translateX(3px); }
.cta-arrow { display: inline-block; transition: transform .2s; }
/* Inner action links should not bubble */
.card-actions { position: relative; z-index: 2; }

/* ============================================================
   Concept modal — interactive panel with V2-style theme swap
   ============================================================ */
body.modal-locked {
  overflow: hidden;
  position: fixed;        /* lock scroll on iOS Safari which ignores overflow:hidden */
  width: 100%;
  overscroll-behavior: none;
}
.modal-scrim {
  overscroll-behavior: contain;
  touch-action: none;     /* the scrim itself eats stray touches; modal-body opts back in */
}
.modal-body {
  touch-action: pan-y;    /* allow vertical scroll inside the body but not page-level */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  transition: background-color 360ms cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-scrim.open { display: flex; animation: scrim-in 200ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
/* Light-mode scrim (mirrors the modal's theme so the surround feels coherent) */
body[data-modal-theme="light"] .modal-scrim { background: rgba(226, 232, 240, 0.78); }

.modal {
  width: min(880px, 100%);
  max-height: 94vh;
  border-radius: 22px;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  animation: modal-in 280ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ----- Theme tokens scoped to the modal ----- */
.modal[data-theme="dark"] {
  --m-bg: #0a1020;
  --m-bg-deep: #05080f;
  --m-surface: #111a33;
  --m-text: #f7f8fb;
  --m-muted: rgba(247, 248, 251, 0.62);
  --m-muted-soft: rgba(247, 248, 251, 0.40);
  --m-border: #1b2747;
  --m-border-hi: #2a3a66;
  --m-accent: #1ea7ff;
  --m-accent-hi: #4fc3ff;
  --m-accent-subtle: rgba(30, 167, 255, 0.12);
}
.modal[data-theme="light"] {
  --m-bg: #ffffff;
  --m-bg-deep: #f1f5f9;
  --m-surface: #f8fafc;
  --m-text: #0a1020;
  --m-muted: rgba(10, 16, 32, 0.62);
  --m-muted-soft: rgba(10, 16, 32, 0.42);
  --m-border: #e2e8f0;
  --m-border-hi: #cbd5e1;
  --m-accent: #007fe0;
  --m-accent-hi: #005faa;
  --m-accent-subtle: rgba(0, 127, 224, 0.08);
}
.modal {
  background: var(--m-bg);
  color: var(--m-text);
}

/* ----- V2 smooth theme swap: only active ~400ms while [data-theming] is set ----- */
.modal[data-theming] *,
.modal[data-theming] *::before,
.modal[data-theming] *::after,
.modal[data-theming] {
  transition:
    background-color 360ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color    360ms cubic-bezier(0.22, 1, 0.36, 1),
    color           360ms cubic-bezier(0.22, 1, 0.36, 1),
    fill            360ms cubic-bezier(0.22, 1, 0.36, 1),
    stroke          360ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow      360ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity         360ms cubic-bezier(0.22, 1, 0.36, 1) !important;
}
@media (prefers-reduced-motion: reduce) {
  .modal[data-theming] *,
  .modal[data-theming] *::before,
  .modal[data-theming] *::after,
  .modal[data-theming] {
    transition-duration: 0.001ms !important;
  }
}

/* ----- View Transitions API: even smoother when supported ----- */
@supports (view-transition-name: a) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 360ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* ----- Header ----- */
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--m-border);
}
.modal-head-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.modal-head-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--m-muted-soft);
  letter-spacing: 0.06em;
}
.modal-family {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--m-accent-hi);
  background: var(--m-accent-subtle);
  border: 1px solid var(--m-accent);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.modal-title {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--m-text);
  word-wrap: break-word;
}
.modal-head-actions {
  flex: 0 0 auto;
}

/* Sun/moon toggle — matches the rest of the portal's toggle */
.modal-theme-toggle, .modal-close {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent;
  color: var(--m-muted);
  border: 1px solid var(--m-border);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 200ms, border-color 200ms, color 200ms, transform 100ms;
}
.modal-theme-toggle:hover, .modal-close:hover {
  background: var(--m-accent-subtle);
  border-color: var(--m-accent);
  color: var(--m-accent-hi);
}
.modal-theme-toggle:active, .modal-close:active { transform: scale(0.96); }
.modal-theme-toggle svg { width: 16px; height: 16px; }
.modal-close { font-size: 22px; line-height: 1; padding-bottom: 4px; }

/* Hide the inactive sun/moon icon so toggle reflects current state */
.modal[data-theme="dark"]  .modal-theme-toggle .icon-moon { display: none; }
.modal[data-theme="light"] .modal-theme-toggle .icon-sun  { display: none; }

/* ----- Body ----- */
.modal-body {
  padding: 32px 28px 26px;
  overflow-y: auto;
  background: var(--m-bg);
  flex: 1 1 auto;        /* take all remaining space; allow keyhints strip below */
  min-height: 0;         /* unlock the scroll behaviour inside the flex parent */
}

/* Stacked logo previews — both variants in DOM, cross-fade on theme swap.
   Fluid sizing so the modal preview is *bigger* than any grid card preview but
   still leaves room for the lockup + downloads without scrolling. */
.modal-icon-stack {
  position: relative;
  width: clamp(260px, 48vmin, 400px);
  height: clamp(260px, 48vmin, 400px);
  margin: 0 auto 22px;
  overflow: hidden;             /* contain the carousel — slides never escape */
  border-radius: 18px;
}
.m-icon-track {
  position: absolute; inset: 0;
  /* Promote the whole track to its own layer for buttery 60fps slides */
  transform: translateZ(0);
  backface-visibility: hidden;
}
.m-slot {
  position: absolute; inset: 0;
  /* iOS-native spring feel: long, smooth deceleration */
  transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  /* Prevent vertical scroll bleed when the user swipes horizontally */
  touch-action: pan-y;
}
.m-slot.no-anim { transition: none; }
.m-slot[data-pos="center"] { transform: translate3d(0, 0, 0); }
.m-slot[data-pos="right"]  { transform: translate3d(100%, 0, 0); }
.m-slot[data-pos="left"]   { transform: translate3d(-100%, 0, 0); }

/* Text BELOW the icon stack — full fade-out, swap, then fade-in.
   Each half is 300ms with a symmetric ease so the in/out feel matches and
   the full 600ms cycle ends in step with the icon-slot slide. */
.modal-lockup-stack,
.modal-blurb,
.modal-head-text {
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.4, 1);
}
.modal-lockup-stack.meta-fade,
.modal-blurb.meta-fade,
.modal-head-text.meta-fade { opacity: 0; }

/* Close-on-swipe-down animation */
.modal-scrim.closing { animation: scrim-out 240ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }
.modal-scrim.closing .modal { animation: modal-out 260ms cubic-bezier(0.4, 0, 0.6, 1) forwards; }
@keyframes scrim-out { to { opacity: 0; } }
@keyframes modal-out { to { transform: translateY(40px); opacity: 0; } }
/* Theme-toggle micro-pulse on the icon-stack */
.modal.theme-pulse .modal-icon-stack { animation: theme-pulse 320ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes theme-pulse { 0% { transform: scale(1); } 35% { transform: scale(0.97); } 100% { transform: scale(1); } }
.modal-icon-stack .m-icon {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 18px;
  border: 1px solid var(--m-border);
  background: var(--m-bg-deep);
  transition: opacity 360ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* Cap the SVG fill so the widest concept overlays (e.g. Triaxial Orbit's
   outer Z ring at r=56 in a 0-160 viewBox) always have breathing room and
   never touch / overflow the slot edges. */
.modal-icon-stack svg {
  width: 78%; height: 78%;
  max-width: 100%; max-height: 100%;   /* never exceed slot */
}

/* Zoom layer — pinch / double-tap / wheel scales the *active* slot's SVG
   without affecting offscreen slots. CSS vars are written by the JS zoom
   controller (attachZoom IIFE in index.html); see also .zoom-grabbing for
   the gesture-in-progress state that disables the transition. */
.modal-icon-stack {
  --zs: 1;
  --zx: 0px;
  --zy: 0px;
  /* When zoomed, prevent the browser from kicking in native pan/zoom for
     two-finger gestures so our handler owns them. */
  touch-action: pan-y;
}
.m-slot[data-pos="center"] svg {
  transform: translate3d(var(--zx, 0px), var(--zy, 0px), 0) scale(var(--zs, 1));
  transform-origin: center center;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.modal-icon-stack.zoom-grabbing .m-slot[data-pos="center"] svg {
  transition: none;
  cursor: grabbing;
}
.modal-icon-stack.is-zoomed { cursor: grab; touch-action: none; }
.modal-icon-stack.is-zoomed.zoom-grabbing { cursor: grabbing; }
.modal[data-theme="dark"]  .m-icon.m-light { opacity: 0; pointer-events: none; }
.modal[data-theme="light"] .m-icon.m-dark  { opacity: 0; pointer-events: none; }
.modal[data-theme="light"] .m-icon { background: var(--m-surface); }

.modal-lockup-stack {
  position: relative;
  width: 100%; max-width: 720px;
  height: clamp(80px, 14vmin, 120px);
  margin: 0 auto 24px;
}
.modal-lockup-stack .m-lockup {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--m-border);
  background: var(--m-bg-deep);
  padding: 14px 22px;
  transition: opacity 360ms cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-lockup-stack svg { width: 100%; max-height: clamp(56px, 10vmin, 96px); }
.modal[data-theme="dark"]  .m-lockup.m-light { opacity: 0; pointer-events: none; }
.modal[data-theme="light"] .m-lockup.m-dark  { opacity: 0; pointer-events: none; }
.modal[data-theme="light"] .m-lockup { background: var(--m-surface); }

.modal-blurb {
  color: var(--m-muted);
  font-size: 14.5px;
  line-height: 1.6;
  text-align: center;
  max-width: 600px;
  margin: 0 auto 24px;
}

.modal-downloads {
  position: relative;
  display: flex; justify-content: center;
  padding-top: 18px;
  border-top: 1px solid var(--m-border);
}
.dl-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 12px;
  background: var(--m-surface);
  color: var(--m-text);
  border: 1px solid var(--m-border);
  border-radius: 999px;
  font: 500 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: background-color 200ms, color 200ms, border-color 200ms;
}
.dl-toggle:hover,
.dl-toggle[aria-expanded="true"] {
  background: var(--m-accent-subtle);
  border-color: var(--m-accent);
  color: var(--m-accent-hi);
}
.dl-toggle svg { flex-shrink: 0; }
.dl-toggle-caret { transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1); }
.dl-toggle[aria-expanded="true"] .dl-toggle-caret { transform: rotate(180deg); }

.dl-menu {
  position: absolute;
  bottom: calc(100% + 4px);            /* opens UPWARD so it doesn't push modal taller */
  left: 50%; transform: translateX(-50%);
  min-width: 200px;
  display: flex; flex-direction: column;
  background: var(--m-surface);
  border: 1px solid var(--m-border-hi);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  z-index: 6;
  animation: dl-pop-in 200ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes dl-pop-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0)    scale(1); }
}
.dl-item {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--m-muted);
  text-decoration: none;
  padding: 11px 16px;
  cursor: pointer;
  transition: background-color 160ms, color 160ms;
  text-align: left;
  border-bottom: 1px solid var(--m-border);
}
.dl-item:last-child { border-bottom: none; }
.dl-item:hover { background: var(--m-accent-subtle); color: var(--m-accent-hi); }

/* ----- Prev / next chevrons — full-height 1/5-width tap zones inside the
   icon stack, with a small theme-tinted glyph centred vertically and
   horizontally inside each tap column. ----- */
.modal-nav {
  position: absolute;
  top: 0; bottom: 0;
  width: 20%;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.modal-nav.prev { left: 0; }
.modal-nav.next { right: 0; }
.chev-glyph {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--m-text);
  opacity: 0.45;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-weight: 300;
  font-size: 22px;
  line-height: 0.6;
  text-shadow: 0 0 10px var(--m-bg-deep), 0 0 5px var(--m-bg-deep);
  transition: opacity 220ms cubic-bezier(0.32, 0.72, 0, 1),
              color   220ms cubic-bezier(0.32, 0.72, 0, 1),
              background-color 220ms cubic-bezier(0.32, 0.72, 0, 1),
              transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-nav:hover .chev-glyph,
.modal-nav:focus-visible .chev-glyph {
  opacity: 1; color: var(--m-accent-hi);
  background: var(--m-accent-subtle);
  transform: scale(1.12);
}
.modal-nav:active .chev-glyph { transform: scale(0.9); }

@media (max-width: 720px) {
  .modal-scrim { padding: 0; }
  .modal { width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
  /* Pin actions to top-right so they're always reachable, regardless of how
     wide the family chip / title gets on narrow viewports. */
  .modal-head { position: relative; padding: 14px 100px 12px 16px; align-items: stretch; }
  .modal-head-actions {
    position: absolute; top: 10px; right: 12px;
    width: 88px;
  }
  .modal-head-actions-inner {
    display: flex; flex-direction: row; gap: 4px;
    justify-content: flex-end; align-items: flex-start;
  }
  .modal-btn-wrap { gap: 2px; }
  .modal-title { font-size: 19px; }
  .modal-body { padding: 22px 16px 100px; }
  .modal-icon-stack { width: min(82vw, 380px); height: min(82vw, 380px); }
  .modal-lockup-stack { width: 100%; height: clamp(72px, 16vw, 110px); }
  .modal-lockup-stack svg { max-height: clamp(56px, 14vw, 88px); }
  .modal-theme-toggle, .modal-close { width: 40px; height: 40px; }   /* fit 40+gap+40 in reserved space */
  /* Chevron tap zones stay full-height, 20% wide on mobile (not the legacy 40px circles) */
  .modal-nav { width: 20%; height: 100%; top: 0; bottom: 0; left: auto; right: auto; }
  .modal-nav.prev { left: 0; }
  .modal-nav.next { right: 0; }
  .chev-glyph { width: 32px; height: 32px; font-size: 22px; }
}

@media (max-width: 420px) {
  .modal-head { padding: 12px 96px 10px 12px; }
  .modal-head-actions { right: 10px; }
  .modal-title { font-size: 17px; }
  .modal-body { padding: 18px 12px 100px; }
  .modal-icon-stack { width: 88vw; height: 88vw; }
  .modal-blurb { font-size: 13.5px; }
  .modal-theme-toggle, .modal-close { width: 38px; height: 38px; }
  .modal-head { padding-right: 96px; }
}

/* ==== Visible labels under modal head buttons ==== */
.modal-head-actions {
  align-self: stretch;
}
.modal-head-actions-inner {
  display: flex; align-items: flex-start; gap: 6px;
}
.modal-btn-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.modal-btn-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--m-muted-soft);
  user-select: none;
}
/* Show only the destination label — when in dark mode, button switches to light */
.modal[data-theme="dark"]  .modal-btn-label .label-dark  { display: none; }
.modal[data-theme="light"] .modal-btn-label .label-light { display: none; }

/* ==== Keyboard hints strip at modal footer ==== */
.modal-keyhints {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  padding: 14px 16px 6px;
  border-top: 1px solid var(--m-border);
  background: var(--m-bg-deep);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--m-muted-soft);
}
.modal-keyhints kbd {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 10px;
  color: var(--m-muted);
}
@media (max-width: 720px) {
  .modal-keyhints { display: none; }   /* no hardware keyboard on phones */
}

/* Critec Digital Twin family tags */
.tag-twin    { color: #7dd3fc; border-color: rgba(56,189,248,0.45); background: rgba(56,189,248,0.10); }
.tag-capture { color: #86efac; border-color: rgba(34,197,94,0.4);  background: rgba(34,197,94,0.10); }
.tag-scan    { color: #fca5a5; border-color: rgba(239,68,68,0.4);  background: rgba(239,68,68,0.10); }
.tag-live    { color: #fcd34d; border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.10); }
.tag-built   { color: #c4b5fd; border-color: rgba(167,139,250,0.4); background: rgba(167,139,250,0.10); }
.tag-type    { color: #f0abfc; border-color: rgba(232,121,249,0.4); background: rgba(232,121,249,0.10); }
