:root {
  --mobile-touch-edge-width: 24px;
  --mobile-touch-transition: 220ms ease;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --footer-annex-height: 28px;
}

.is-touch-layout {
  --touch-layout-enabled: 1;
}

.is-touch-layout .navigation-surface {
  bottom: calc(28px + var(--mobile-safe-bottom));
  transform: scale(0.9);
  transform-origin: right bottom;
}

.is-touch-layout .footer-annex {
  padding-bottom: var(--mobile-safe-bottom);
}

.is-touch-layout #meta.footer-main {
  display: none;
}

/* Header: not enough width on phone screens to reserve the same fixed space for the
   zoom control + stats + space switch as on desktop — the logo/breadcrumb would wrap
   to a second line. Shrink the right-side controls and drop the least essential piece
   (the raw zoom count, already secondary) instead of the logo/breadcrumb. */
.is-touch-layout .orbit-breadcrumb {
  max-width: calc(100% - 170px);
  gap: 6px;
}

.is-touch-layout .orbit-space-switch-item {
  padding: 0 7px;
  font-size: 10px;
}

.is-touch-layout .orbit-zoom-stats {
  display: none;
}

/* Touch layout frame: remove the hidden footer row from the main app grid */
.app-container.is-touch-layout {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  grid-template-rows: 40px minmax(0, 1fr) 0 auto;
}

.app-container.is-touch-layout .structural-spaces,
.app-container.is-touch-layout .grid-space,
.app-container.is-touch-layout .gallery-root,
.app-container.is-touch-layout #gallery-container {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}


.is-touch-layout.mobile-screen-grid-cluster #gallery-container,
.is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 40%);
  overflow: hidden;
  background: var(--surface-deep);
}

.is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster.mobile-grid-cluster--no-supporting {
  background: var(--surface-base);
}

.is-touch-layout.mobile-screen-grid-cluster .media-carousel > .entity-summary {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.62);
  border-bottom: 1px solid var(--color-border-soft);
}



.is-touch-layout.mobile-screen-grid-cluster .media-carousel,
.is-touch-layout.mobile-screen-grid-cluster .media-carousel__track,
.is-touch-layout.mobile-screen-grid-cluster .media-carousel__item,
.is-touch-layout.mobile-screen-grid-cluster .media-frame {
  height: 100%;
}

.is-touch-layout.mobile-screen-grid-cluster .media-carousel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.is-touch-layout.mobile-screen-grid-cluster .media-carousel__item,
.is-touch-layout.mobile-screen-grid-cluster .media-frame {
  background: var(--surface-deep);
}



.is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster__info {
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface-base);
}

.is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster__context-surface {
  border-top: 1px solid var(--color-border-soft);
}

@media (orientation: landscape) {
  .app-container.is-touch-layout {
    grid-template-rows: 40px minmax(0, 1fr) 0 auto;
  }

  .is-touch-layout .footer-annex {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    height: auto;
    min-height: var(--footer-annex-height);
    padding-top: 0;
    padding-bottom: 0;
  }

  .is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster {
    display: grid;
    grid-template-columns: minmax(0, 60%) minmax(0, 40%);
    grid-template-rows: minmax(0, 1fr) clamp(52px, 10dvh, 72px);
    min-height: 0;
    height: 100%;
    max-height: none;
  }

  .is-touch-layout.mobile-screen-grid-cluster .media-carousel {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
  }

  .is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster__context-surface {
    grid-column: 2;
    grid-row: 1 / 3;
    min-height: 0;
    max-height: none;
    border-top: 0;
    border-left: 1px solid var(--color-border-soft);
  }

  .is-touch-layout.mobile-screen-grid-cluster .mobile-grid-cluster__info {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-top: 0;
  }

}




.is-touch-layout.mobile-screen-grid-viewer #gallery-overlay,
.is-touch-layout.mobile-screen-grid-info #gallery-overlay {
  background: var(--surface-deep);
}

.is-touch-layout.mobile-screen-grid-viewer .viewer-svg,
.is-touch-layout.mobile-screen-grid-info .viewer-svg {
  background: var(--surface-deep) !important;
}

.is-touch-layout.mobile-screen-grid-viewer .viewer-svg {
  width: 100% !important;
  height: calc(100% - 18px) !important;
}

.is-touch-layout.mobile-screen-grid-info .viewer-svg {
  width: 100% !important;
  height: 60% !important;
}

.is-touch-layout .mobile-viewer,
.is-touch-layout .media-viewer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.is-touch-layout .media-carousel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.is-touch-layout .media-carousel__track {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.is-touch-layout .media-carousel__track::-webkit-scrollbar {
  display: none;
}

.is-touch-layout .media-carousel__item {
  position: relative;
  flex: 0 0 100%;
  min-width: 100%;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
}

.is-touch-layout .media-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.is-touch-layout .media-frame__media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 1;
}

.is-touch-layout .media-frame__fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--color-text-muted);
  font-family: var(--font-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.media-progress-bar,
.is-touch-layout .media-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 9;
  width: 3px;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
  display: block;
}

.media-progress-bar__thumb,
.is-touch-layout .media-progress-bar__thumb {
  position: absolute;
  left: 0;
  width: 100%;
  background: var(--accent);
  transition: top 220ms ease, height 220ms ease;
}

.media-progress-bar[hidden] {
  display: none;
}

.is-touch-layout .media-viewer > .media-progress-bar {
  z-index: 10;
}

.is-touch-layout .entity-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 5px;
  min-height: 0;
  overflow: hidden;
}

.is-touch-layout .entity-summary__title {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-meta);
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.is-touch-layout .entity-summary__id {
  color: var(--color-text-muted);
  font-family: var(--font-meta);
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.is-touch-layout .media-viewer > .entity-badge {
  position: absolute;
  top: 18px;
  right: 0;
  z-index: 8;
}

.is-touch-layout .surface-handle {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--gray-111);
  color: var(--color-text-main);
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
  transform: none;
}

.is-touch-layout .surface-handle--top,
.is-touch-layout .surface-handle--bottom {
  width: 100%;
  height: 18px;
  min-height: 18px;
}

.is-touch-layout .surface-handle--top {
  border-bottom: 1px solid var(--color-border-soft);
}

.is-touch-layout .surface-handle--bottom {
  border-top: 1px solid var(--color-border-soft);
}

.is-touch-layout .surface-handle--left,
.is-touch-layout .surface-handle--right {
  width: 18px;
  height: 100%;
}

.is-touch-layout .surface-handle--left {
  border-right: 1px solid var(--color-border-soft);
}

.is-touch-layout .surface-handle--right {
  border-left: 1px solid var(--color-border-soft);
}


.is-touch-layout.mobile-screen-grid-viewer .media-viewer > .surface-handle {
  position: absolute;
  right: 0;
  bottom: var(--mobile-safe-bottom);
  left: 0;
  z-index: 8;
}

/* Context surface: always in DOM, slides in/out via transform */
.is-touch-layout .mobile-viewer-context-surface {
  position: absolute;
  inset: auto 0 0;
  --mobile-context-surface-width: 100%;
  --mobile-context-surface-height: 40%;
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 220ms ease;
}

.is-touch-layout.mobile-screen-grid-info .media-viewer > .entity-badge,
.is-touch-layout.mobile-screen-grid-info .media-viewer > .surface-handle {
  display: none;
}

/* Viewer context surface — open state */
.is-touch-layout.mobile-screen-grid-info .mobile-viewer-context-surface {
  transform: translateY(0);
  pointer-events: auto;
}

.is-touch-layout .mobile-viewer-context-surface > .surface-handle {
  position: static;
  z-index: auto;
}

@media (orientation: landscape) {
  .is-touch-layout.mobile-screen-grid-viewer .viewer-svg {
    width: calc(100% - 18px) !important;
    height: 100% !important;
  }

  .is-touch-layout.mobile-screen-grid-info .viewer-svg {
    width: 60% !important;
    height: 100% !important;
  }

  .is-touch-layout.mobile-screen-grid-viewer .media-viewer > .entity-badge {
    right: 18px;
  }

  /* Surface: right 40% panel, slides from right */
  .is-touch-layout .mobile-viewer-context-surface {
    inset: 0 0 0 auto;
    --mobile-context-surface-width: 40%;
    --mobile-context-surface-height: 100%;
    transform: translateX(100%);
  }

  .is-touch-layout.mobile-screen-grid-info .mobile-viewer-context-surface {
    transform: translateX(0);
  }

  /* Opener handle: vertical strip on right edge */
  .is-touch-layout.mobile-screen-grid-viewer .media-viewer > .surface-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
  }
}

.is-touch-layout.mobile-screen-grid-viewer .item-detail-overlay,
.is-touch-layout.mobile-screen-grid-info .item-detail-overlay,
.is-touch-layout.mobile-screen-grid-viewer .viewer-relation-surface-frame,
.is-touch-layout.mobile-screen-grid-info .viewer-relation-surface-frame {
  display: none;
}


.is-touch-layout .entity-badge {
  padding: 4px 4px 4px 8px;
  background: rgb(0 0 0 / 79%);
  border: 0;
  border-radius: 20px 0 0 20px;
  color: var(--color-text-main);
  font-family: var(--font-meta);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
  pointer-events: none;
}

.is-touch-layout .media-carousel > .entity-badge {
  position: absolute;
  top: 18px;
  right: 0;
  z-index: 9;
  pointer-events: none;
}

.is-touch-layout .surface-handle--top::before,
.is-touch-layout .surface-handle--bottom::before {
  content: "";
  width: 50px;
  height: 5px;
  border-radius: 999px;
  background: var(--color-text-muted);
}

.is-touch-layout .surface-handle--left::before,
.is-touch-layout .surface-handle--right::before {
  content: "";
  width: 5px;
  height: 50px;
  border-radius: 999px;
  background: var(--color-text-muted);
}

@media (orientation: landscape) {
  .is-touch-layout .surface-handle--landscape-left,
  .is-touch-layout .surface-handle--landscape-right {
    width: 18px;
    height: 100%;
    min-height: 0;
    border-top: 0;
    border-bottom: 0;
  }

  .is-touch-layout .surface-handle--landscape-left {
    border-right: 1px solid var(--color-border-soft);
  }

  .is-touch-layout .surface-handle--landscape-right {
    border-left: 1px solid var(--color-border-soft);
  }

  .is-touch-layout .surface-handle--landscape-left::before,
  .is-touch-layout .surface-handle--landscape-right::before {
    width: 5px;
    height: 50px;
  }
}

.is-touch-layout .surface-handle[hidden] {
  display: none;
}

.is-touch-layout .mobile-context-surface {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr) 34px;
  width: var(--mobile-context-surface-width, 100%);
  height: var(--mobile-context-surface-height, 100%);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-panel);
}

.is-touch-layout .mobile-context-surface--handle-top {
  grid-template-rows: 18px minmax(0, 1fr);
}

.is-touch-layout .mobile-context-surface--handle-bottom {
  grid-template-rows: minmax(0, 1fr) 18px;
}

.is-touch-layout .mobile-context-surface__content {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: var(--surface-base);
}

.is-touch-layout .mobile-context-surface__panel {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.is-touch-layout .mobile-context-surface > .surface-tabs {
  grid-column: 2;
  grid-row: 1;
  width: 34px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--color-border-soft);
  background: var(--surface-panel);
}

.is-touch-layout .mobile-context-surface--with-handle > .surface-handle {
  grid-column: 1 / -1;
}

.is-touch-layout .mobile-context-surface--handle-top > .surface-handle {
  grid-row: 1;
}

.is-touch-layout .mobile-context-surface--handle-top > .mobile-context-surface__content,
.is-touch-layout .mobile-context-surface--handle-top > .surface-tabs {
  grid-row: 2;
}

.is-touch-layout .mobile-context-surface--handle-bottom > .surface-handle {
  grid-row: 2;
}

@media (orientation: landscape) {
  .is-touch-layout .mobile-context-surface--landscape-handle-left {
    grid-template: minmax(0, 1fr) / 18px minmax(0, 1fr) 34px;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-left > .surface-handle {
    grid-column: 1;
    grid-row: 1;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-left > .mobile-context-surface__content {
    grid-column: 2;
    grid-row: 1;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-left > .surface-tabs {
    grid-column: 3;
    grid-row: 1;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-right {
    grid-template: minmax(0, 1fr) / minmax(0, 1fr) 34px 18px;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-right > .mobile-context-surface__content {
    grid-column: 1;
    grid-row: 1;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-right > .surface-tabs {
    grid-column: 2;
    grid-row: 1;
  }

  .is-touch-layout .mobile-context-surface--landscape-handle-right > .surface-handle {
    grid-column: 3;
    grid-row: 1;
  }
}

.is-touch-layout .mobile-context-surface__panel[hidden] {
  display: none;
}

.is-touch-layout .info-panel,
.is-touch-layout .relations-panel {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.is-touch-layout .relations-panel {
  padding: 0;
  overflow: auto;
}

.is-touch-layout .supporting-panel {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: transparent;
}

.is-touch-layout .supporting-panel__track {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  align-content: start;
  gap: 2px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 2px;
  overflow: visible;
}

.is-touch-layout .supporting-panel__item {
  position: relative;
  flex: none;
  width: 100%;
  min-width: 0;
  height: 0;
  padding: 0;
  padding-bottom: 100%;
  border: 0;
  outline: 0;
  background: var(--gray-111);
  cursor: pointer;
  overflow: hidden;
}

.is-touch-layout .supporting-panel__thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
  transition: opacity 140ms ease;
}

.is-touch-layout .supporting-panel__item:hover .supporting-panel__thumb,
.is-touch-layout .supporting-panel__item:focus-visible .supporting-panel__thumb {
  opacity: 1;
}

.is-touch-layout .supporting-panel__thumb--fallback {
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--color-text-main);
  font-family: var(--font-meta);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.is-touch-layout .info-panel__body {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: var(--surface-base);
}

.is-touch-layout .relations-panel__body {
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.is-touch-layout .surface-tabs {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 0;
}

.is-touch-layout .surface-tabs__tab {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  opacity: .72;
}

.is-touch-layout .surface-tabs__tab.is-active {
  color: var(--accent);
  opacity: 1;
  pointer-events: none;
}

.is-touch-layout .surface-tabs__tab:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

.is-touch-layout .surface-tabs__icon {
  width: 16px;
  height: 16px;
  color: currentColor;
}

.is-touch-layout .surface-tabs__icon :is(path, rect, circle, polygon) {
  fill: currentColor;
}

.is-touch-layout .surface-tabs__icon :is(line, polyline),
.is-touch-layout .surface-tabs__icon [stroke] {
  stroke: currentColor;
}

.app-container:not(.is-touch-layout) .mobile-drift-context-surface,
.drift-mobile-focus-reticle { display: none; }

.app-container.is-touch-layout.mobile-screen-drift-main .spatial-monitor,
.app-container.is-touch-layout.mobile-screen-drift-context .spatial-monitor { display: none; }

.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .relation-panel {
  position: relative;
  overflow: hidden;
}
.app-container.is-touch-layout.mobile-screen-drift-main .relation-panel-graph-column {
  inset: 0 0 18px;
}
.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel-graph-column {
  position: absolute;
  inset: 40% 0 18px;
  display: grid;
  transition: inset var(--mobile-touch-transition);
}
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .relation-graph-container {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  transition: inset var(--mobile-touch-transition);
}
.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel-context-column {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  display: flex;
  width: 100%;
  max-width: none;
  height: 40%;
  border: 0;
  border-bottom: 1px solid var(--color-border-soft);
  border-radius: 0;
  transform: none;
  transition: transform var(--mobile-touch-transition);
}
.app-container.is-touch-layout.mobile-screen-drift-context .surface-collapse-handle--context,
.app-container.is-touch-layout.mobile-screen-drift-context .relation-context--desktop { display: none; }

.app-container.is-touch-layout.mobile-screen-drift-context .drift-surface-panel--context {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--surface-panel);
}
.app-container.is-touch-layout.mobile-screen-drift-context .drift-surface-panel--context > .relation-panel-strip { display: none; }

.app-container.is-touch-layout.mobile-screen-drift-context .mobile-drift-context-surface__panel--cover:not([hidden]) {
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.app-container.is-touch-layout.mobile-screen-drift-context .media-carousel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 26px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.app-container.is-touch-layout.mobile-screen-drift-context .media-carousel__track {
  display: flex;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}
.app-container.is-touch-layout.mobile-screen-drift-context .media-carousel__track::-webkit-scrollbar { display: none; }
.app-container.is-touch-layout.mobile-screen-drift-context .media-carousel__item,
.app-container.is-touch-layout.mobile-screen-drift-context .media-frame {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--surface-deep);
  color: var(--color-text-muted);
}
.app-container.is-touch-layout.mobile-screen-drift-context .entity-summary__title {
  font-size: 11px;
}

.app-container.is-touch-layout.mobile-screen-drift-context .media-progress-bar {
  bottom: 26px;
}

.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .relation-panel-graph-column {
  position: absolute;
}
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 20;
  display: block;
  width: 150px;
  height: 150px;
  color: var(--color-focus-ring);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.2;
}
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle svg {
  display: block;
  width: 100%;
  height: 100%;
}
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle :is(path, rect, circle, polygon) { fill: currentColor; }
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle :is(line, polyline),
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle [stroke] { stroke: currentColor; }
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle .focus {
  opacity: 1;
  fill: currentColor;
}

@keyframes reticle-corner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); }
}

.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle.is-panning {
  opacity: 0.85;
}

.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .drift-mobile-focus-reticle.is-panning .focus path:nth-child(-n+4) {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: reticle-corner-pulse 1.6s ease-in-out infinite;
}
.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-mobile-context-collapsed .relation-panel-graph-column {
  top: 18px;
  bottom: 18px;
}
/* ── Mobile drift control surface ────────────────────────────────────────── */

.app-container.is-touch-layout .mobile-drift-control {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: visible;
}

/* ── Nav panel — slides from bottom, handle peeks at top when closed ── */
.app-container.is-touch-layout .mobile-drift-nav-panel {
  position: absolute;
  top: auto;
  bottom: -18px;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 40vh;
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  transform: translateY(calc(100% - 18px));
  transition: transform 220ms ease;
  pointer-events: auto;
  overflow: hidden;
  font-family: var(--font-meta);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.app-container.is-touch-layout .mobile-drift-control.is-nav-open .mobile-drift-nav-panel {
  bottom: 0;
  transform: translateY(0);
}

/* Nav panel body — shared stack: minimap above axes */
.app-container.is-touch-layout .mobile-drift-nav-panel__body {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  gap: 10px;
  padding: 10px 12px 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Axes column */
.app-container.is-touch-layout .mobile-drift-nav-panel__axes-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

/* Minimap */
.app-container.is-touch-layout .mobile-drift-nav-panel__map {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
}

.app-container.is-touch-layout .mobile-drift-nav-panel__map-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.app-container.is-touch-layout .mobile-drift-nav-panel__map-svg.is-dragging-viewport {
  cursor: grabbing;
}

/* Axes list — scrollable, desktop axis style */
.app-container.is-touch-layout .mobile-drift-nav-panel__axes {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
  min-height: 0;
  justify-content: space-between;
}
.app-container.is-touch-layout .mobile-drift-nav-panel__axes::-webkit-scrollbar { display: none; }

/* Suppress Safari hover-stuck state on axis buttons (touch leaves :hover active) */
.app-container.is-touch-layout .mobile-drift-nav-panel .spatial-monitor__axis:hover:not(.is-active) {
  color: var(--color-text-muted);
}
.app-container.is-touch-layout .mobile-drift-nav-panel .spatial-monitor__axis:hover:not(.is-active) .spatial-monitor__axis-bar-fill {
  opacity: 0.42;
}
.app-container.is-touch-layout .mobile-drift-nav-panel .spatial-monitor__axis:hover:not(.is-active) .spatial-monitor__axis-count {
  opacity: 0.72;
}

/* Stats row — full width below body */
.app-container.is-touch-layout .mobile-drift-nav-panel__stats {
  flex-shrink: 0;
  margin: 0;
  padding: 5px 12px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}


/* Handle at top of panel — full width, static (not absolute) */
.app-container.is-touch-layout .mobile-drift-nav-panel > .surface-handle {
  flex: 0 0 18px;
  position: static;
  order: -1;
}

/* ── Persistent overlay ── */
.app-container.is-touch-layout .mobile-drift-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.app-container.is-touch-layout .mobile-drift-overlay__group {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-container.is-touch-layout .mobile-drift-overlay__btn {
  pointer-events: auto;
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  font-size: 9px;
}

/* Separator between REL and C/P/T */
.app-container.is-touch-layout .mobile-drift-overlay__sep {
  width: 20px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 1px 0;
  align-self: center;
}

/* Left group: REL + sep + C/P/T + depth row */
.app-container.is-touch-layout .mobile-drift-overlay__group--left {
  left: 6px;
  top: 6px;
}

/* Right group: CLU / SPT / ORP */
.app-container.is-touch-layout .mobile-drift-overlay__group--right {
  right: 6px;
  top: 6px;
}

/* Bottom group: full-width column — buttons right, info right, zoom full-width */
.app-container.is-touch-layout .mobile-drift-overlay__group--bottom {
  flex-direction: column;
  align-items: flex-end;
  left: 6px;
  right: 6px;
  bottom: 10px;
  gap: 3px;
}

.app-container.is-touch-layout .mobile-drift-overlay__btn-row {
display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.app-container.is-touch-layout .mobile-drift-overlay__btn-group {
  display: flex;
  flex-direction: row;
  gap: 4px;
}

/* Scale / position info — always visible below FIT/RST */
.app-container.is-touch-layout .mobile-drift-overlay__info {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.app-container.is-touch-layout .mobile-drift-overlay__info-item {
  font-family: var(--font-meta, monospace);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--color-text-main);
  opacity: 0.72;
  line-height: 1;
}

/* Zoom slider row — full width, on graph overlay */
.app-container.is-touch-layout .mobile-drift-overlay__zoom {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.app-container.is-touch-layout .mobile-drift-overlay__zoom-btn {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  min-width: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.app-container.is-touch-layout .mobile-drift-overlay__zoom-slider {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  margin: 0;
  padding: 0;
  pointer-events: auto;
}
.app-container.is-touch-layout .mobile-drift-overlay__zoom-slider::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
.app-container.is-touch-layout .mobile-drift-overlay__zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 1px solid var(--color-text-main);
  border-radius: 50%;
  background: var(--gray-111, #111);
}
.app-container.is-touch-layout .mobile-drift-overlay__zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-text-main);
  border-radius: 50%;
  background: var(--gray-111, #111);
}

/* Depth row: button + sibling dots outside button, dots stack vertically */
.app-container.is-touch-layout .mobile-drift-overlay__depth-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.app-container.is-touch-layout .mobile-drift-overlay__depth-row .spatial-monitor__depth-dots {
  display: grid;
  grid-template-columns: 4px;
  gap: 2px;
}

/* Hide the relation graph legend on mobile — replaced by overlay buttons */
.app-container.is-touch-layout .relation-graph-legend { display: none; }

/* Context column slides away when nav panel is open */
.app-container.is-touch-layout .relation-panel.is-nav-panel-open .relation-panel-context-column {
  transform: translateY(calc(-100% + 18px));
  pointer-events: auto;
}

/* Surface N stays anchored while the graph uses only the remaining space. */
.app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .relation-panel.is-nav-panel-open .relation-panel-graph-column {
  inset: 0;
}

.app-container.is-touch-layout.mobile-screen-drift-main .relation-panel.is-nav-panel-open .relation-graph-container,
.app-container.is-touch-layout.mobile-screen-drift-main .mobile-drift-control.is-nav-open .mobile-drift-overlay {
  inset: 0 0 40vh;
}

.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-nav-panel-open .relation-graph-container,
.app-container.is-touch-layout.mobile-screen-drift-context .mobile-drift-control.is-nav-open .mobile-drift-overlay {
  inset: 18px 0 40vh;
}

.app-container.is-touch-layout.mobile-screen-drift-main .relation-panel.is-nav-panel-open .drift-mobile-focus-reticle {
  top: calc((100% - 40vh) / 2);
}

.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-nav-panel-open .drift-mobile-focus-reticle {
  top: calc(18px + ((100% - 40vh - 18px) / 2));
}

.app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-mobile-context-collapsed .relation-panel-context-column {
  transform: translateY(calc(-100% + 18px));
}

/* ── Drift landscape layout ── */
@media (orientation: landscape) {
  /* Nav panel: right 40%, slides from right, handle on left side */
  .app-container.is-touch-layout .mobile-drift-nav-panel {
    top: 0;
    left: auto;
    right: -18px;
    bottom: 0;
    width: 40%;
    height: 100%;
    display: grid;
    grid-template: 1fr auto / 18px 1fr;
    transform: translateX(calc(100% - 18px));
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.07);
  }

  .app-container.is-touch-layout .mobile-drift-control.is-nav-open .mobile-drift-nav-panel {
    right: 0;
    transform: translateX(0);
  }

  .app-container.is-touch-layout .mobile-drift-nav-panel__body {
    grid-column: 2;
    grid-row: 1;
  }

  .app-container.is-touch-layout .mobile-drift-nav-panel__stats {
    grid-column: 2;
    grid-row: 2;
  }

  /* Nav handle: left vertical strip spanning full height */
  .app-container.is-touch-layout .mobile-drift-nav-panel > .surface-handle {
    grid-column: 1;
    grid-row: 1 / -1;
    flex: none;
    order: initial;
  }

  /* Context column: left 40%, slides from left */
  .app-container.is-touch-layout.mobile-screen-drift-main .relation-panel-graph-column {
    inset: 0 18px 0 0;
  }

  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel-graph-column {
    inset: 0 18px 0 40%;
  }

  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel-context-column {
    inset: 0 auto 0 0;
    width: 40%;
    height: 100%;
    border-top: 0;
    border-bottom: 0;
    border-right: 1px solid var(--color-border-soft);
  }

  /* Collapsed: peek 18px handle from left edge */
  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-mobile-context-collapsed .relation-panel-context-column {
    transform: translateX(calc(-100% + 18px));
  }

  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-mobile-context-collapsed .relation-panel-graph-column {
    inset: 0 18px 0 18px;
  }

  /* Nav open: context stays collapsed with its handle available */
  .app-container.is-touch-layout .relation-panel.is-nav-panel-open .relation-panel-context-column {
    transform: translateX(calc(-100% + 18px));
  }

  /* Nav open: graph expands to full width */
  .app-container.is-touch-layout:is(.mobile-screen-drift-main, .mobile-screen-drift-context) .relation-panel.is-nav-panel-open .relation-panel-graph-column {
    inset: 0;
  }

  .app-container.is-touch-layout.mobile-screen-drift-main .relation-panel.is-nav-panel-open .relation-graph-container,
  .app-container.is-touch-layout.mobile-screen-drift-main .mobile-drift-control.is-nav-open .mobile-drift-overlay {
    inset: 0 40% 0 0;
  }

  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-nav-panel-open .relation-graph-container,
  .app-container.is-touch-layout.mobile-screen-drift-context .mobile-drift-control.is-nav-open .mobile-drift-overlay {
    inset: 0 40% 0 18px;
  }

  .app-container.is-touch-layout.mobile-screen-drift-main .relation-panel.is-nav-panel-open .drift-mobile-focus-reticle {
    left: calc((100% - 40%) / 2);
  }

  .app-container.is-touch-layout.mobile-screen-drift-context .relation-panel.is-nav-panel-open .drift-mobile-focus-reticle {
    left: calc(18px + ((100% - 40% - 18px) / 2));
  }
}
