:root {
  --scope-surface-rail-width: 96px;
  --scope-room-cyan: #00e5ff;
  --scope-room-amber: #f6c85f;
  --scope-room-panel: rgba(9, 14, 19, 0.86);
}

.scope-surface-rail {
  position: absolute;
  top: 50%;
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: calc(var(--scope-layer-priority-control) + 5);
  display: flex;
  transform: translateY(-50%);
  pointer-events: auto;
}

.scope-surface-rail .bento-rail {
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    inset 0 0 18px rgba(0, 229, 255, 0.05);
}

/* A utility sheet temporarily owns the right-side interaction lane. Dim the
   rail and remove its hit targets until the scope settings sheet closes. */
.scope-overlay:has(> .scope-kebab-menu.scope-kebab-menu--open) > .scope-surface-rail {
  opacity: 0.28;
  pointer-events: none;
}

.scope-knomad-instrument {
  position: absolute;
  top: 50%;
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: calc(var(--scope-layer-priority-control) + 4);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(500px, calc(50vw - var(--scope-housing-radius) - 24px));
  min-width: 0;
  color: rgba(239, 248, 252, 0.96);
  font-family: var(--scope-font-instrument, 'Roboto Mono', monospace);
  pointer-events: auto;
  transform: translateY(-50%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.scope-knomad-instrument__identity {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-bottom: 4px;
  text-shadow: 0 1px 4px #000;
}

.scope-knomad-instrument__eyebrow,
.scope-knomad-instrument__answer-label {
  color: rgba(0, 229, 255, 0.76);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.scope-knomad-instrument__name {
  overflow: hidden;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-knomad-instrument__disk {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  border-radius: 50%;
  cursor: grab;
  box-shadow:
    0 16px 22px rgba(0, 0, 0, 0.62),
    0 0 8px rgba(0, 229, 255, 0.12);
  outline: none;
  touch-action: none;
}

.scope-knomad-instrument__disk.preview {
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}

.scope-knomad-instrument--rotating .scope-knomad-instrument__disk {
  cursor: grabbing;
  box-shadow:
    0 16px 22px rgba(0, 0, 0, 0.62),
    0 0 12px rgba(0, 229, 255, 0.3);
}

.scope-knomad-instrument:focus-visible .scope-knomad-instrument__disk {
  outline: 2px solid rgba(0, 229, 255, 0.72);
  outline-offset: 3px;
}

.scope-knomad-instrument__disk .knomad-context-visual {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.scope-knomad-instrument__disk [data-knomad-source-id="spiralTransformGroup"] {
  transform-origin: 0 0;
  will-change: transform;
}

.scope-knomad-instrument__visual-empty {
  color: var(--scope-room-cyan);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.scope-knomad-instrument__answers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  margin-top: 4px;
  border-top: 1px solid rgba(0, 229, 255, 0.24);
  border-bottom: 1px solid rgba(0, 229, 255, 0.16);
  text-shadow: 0 1px 4px #000;
}

.scope-knomad-instrument__answer {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 7px 5px;
  text-align: center;
}

.scope-knomad-instrument__answer + .scope-knomad-instrument__answer {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.scope-knomad-instrument__answer-label {
  display: block;
}

.scope-knomad-instrument__answer-value {
  overflow: hidden;
  font-size: clamp(10px, 1vw, 13px);
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scope-knomad-instrument__instruction {
  margin: 6px 0 0;
  color: rgba(220, 229, 234, 0.54);
  font-size: 8px;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 1px 4px #000;
  text-transform: uppercase;
}

.scope-knomad-instrument--hidden,
.scope-knomad-instrument--parked {
  opacity: 0;
  transform: translate(-18px, -50%);
  pointer-events: none;
}

/* The Data Book is the rail's DB in the glass too, so the glass's own logbook control stays hidden. EXIT SIM FIRE
   shows: the rail holds no exit (one right rail), and the glass leaves by its own button, Escape, or the page row. */
body.field-tools--desktop.scope-surface-rail--active .scope-logbook-control {
  display: none !important;
}

/* GLASS-MENU-1: the ⋮ stands in EXIT SIM FIRE's row, 12 px to its left, its centre on the exit's (40 px tall from 16:
   the ⋮'s 32 from 20). It sat inside the exit over its × (a press on the × opened the settings; one on the ⋮'s edge
   left the glass), so its right is the exit's right plus the exit's fixed width plus the gap, never a rail offset. */
body.field-tools--desktop.scope-surface-rail--active .scope-kebab-btn {
  top: max(20px, calc(env(safe-area-inset-top, 0px) + 20px));
  right: calc(max(16px, env(safe-area-inset-right, 0px)) + var(--scope-desktop-exit-width, 156px) + 12px);
}

body.field-tools--desktop.scope-surface-rail--active .scope-kebab-menu {
  top: max(62px, calc(env(safe-area-inset-top, 0px) + 62px));
  right: calc(var(--scope-surface-rail-width) + 32px);
  z-index: calc(var(--scope-layer-priority-control) + 7);
  max-height: calc(100dvh - 180px);
}

body.field-tools--desktop.scope-surface-rail--active .scope-utility-card--right {
  right: calc(var(--scope-surface-rail-width) + 32px);
}

@media (orientation: landscape) {
  .scope-overlay > .scope-surface-rail,
  .scope-overlay > .scope-knomad-instrument {
    visibility: visible;
    opacity: 1;
  }

  .scope-overlay > .scope-knomad-instrument--hidden,
  .scope-overlay > .scope-knomad-instrument--parked {
    opacity: 0;
  }
}

@media (max-height: 700px) {
  .scope-knomad-instrument__instruction {
    display: none;
  }

  .scope-knomad-instrument__answer {
    padding-block: 4px;
  }
}
