:root {
  --bg: #06070d;
  --fg: #d9f7ff;
  --dim: #8fb4c2;
  --panel: rgba(10, 14, 26, 0.82);
  --line: #1f6f84;
  --cyan: #19e3ff;
  --magenta: #ff2bd6;
  --amber: #ffb000;
  --btn: #0c1a28;
  --btn-fg: #19e3ff;
  --warn: #2a2108;
  --ph: #0b1220;
  --glow: 0 0 8px rgba(25, 227, 255, 0.55);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
:root[data-theme='light'] {
  --on-cyan: #fff;
  --bg: #eef4f6;
  --fg: #10222a;
  --dim: #3d5a66;
  --panel: rgba(255, 255, 255, 0.9);
  --line: #4a8fa3;
  --cyan: #006f88;
  --magenta: #a3007f;
  --amber: #8a5a00;
  --btn: #ffffff;
  --btn-fg: #005a70;
  --warn: #fff1c9;
  --ph: #dbe7ec;
  --glow: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  font:
    16px/1.45 system-ui,
    sans-serif;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(25, 227, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 227, 255, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
}
:root[data-theme='light'] body {
  background-image:
    linear-gradient(rgba(0, 111, 136, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 111, 136, 0.08) 1px, transparent 1px);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.14) 0 1px,
    transparent 1px 3px
  );
  opacity: 0.5;
  animation: scan 8s linear infinite;
}
:root[data-theme='light'] body::after {
  display: none;
}
@keyframes scan {
  to {
    background-position: 0 12px;
  }
}
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.55;
}
.top,
main,
footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-top: 16px;
}
h1 {
  font: 700 1.5rem var(--mono);
  letter-spacing: 0.12em;
  margin: 0 0 4px;
  color: var(--cyan);
  text-shadow: var(--glow);
}
h2 {
  font: 700 0.95rem var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 10px;
  color: var(--cyan);
}
h3 {
  font: 700 0.8rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 14px 0 6px;
  color: var(--amber);
}
.lede,
.hint {
  margin: 4px 0 8px;
  color: var(--dim);
}
.hint {
  font-size: 0.88rem;
}
.glitch {
  animation: glitch 0.9s steps(2, end) 1;
}
@keyframes glitch {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-3px, 1px);
    text-shadow:
      3px 0 var(--magenta),
      -3px 0 var(--cyan);
  }
  40% {
    transform: translate(3px, -1px);
  }
  60% {
    transform: translate(-2px, 0);
    text-shadow: -2px 0 var(--magenta);
  }
  100% {
    transform: none;
  }
}
.top-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}
.light {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 10px var(--magenta);
  animation: pulse 2s ease-in-out infinite;
}
.light.on {
  background: #2cff9a;
  box-shadow: 0 0 10px #2cff9a;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  margin: 14px 0;
}
@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1fr 1.4fr 1fr;
    align-items: start;
  }
  .wide {
    grid-column: span 2;
  }
}
.panel,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  position: relative;
  backdrop-filter: blur(3px);
  box-shadow: inset 0 0 18px rgba(25, 227, 255, 0.07);
}
.panel {
  animation: slide 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes slide {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.panel::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 16px;
  height: 16px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}
.notice {
  background: var(--warn);
  border-color: var(--amber);
}
.notice h2 {
  color: var(--amber);
}
form {
  display: grid;
  gap: 8px;
}
label {
  display: grid;
  gap: 3px;
  font-weight: 600;
}
.check {
  display: flex;
  gap: 8px;
  align-items: center;
}
.check input {
  width: 24px;
  height: 24px;
  accent-color: var(--cyan);
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 12px 0 0;
  padding: 8px 10px;
}
legend {
  font: 0.8rem var(--mono);
  color: var(--dim);
  padding: 0 4px;
}
input[type='url'],
input[type='password'] {
  font: inherit;
  padding: 6px 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg);
  width: 100%;
}
:root[data-theme='light'] input[type='url'],
:root[data-theme='light'] input[type='password'] {
  background: #fff;
}
button {
  font: 600 0.9rem var(--mono);
  letter-spacing: 0.05em;
  min-height: 36px;
  min-width: 36px;
  padding: 4px 14px;
  border-radius: 4px;
  border: 1px solid var(--cyan);
  background: var(--btn);
  color: var(--btn-fg);
  cursor: pointer;
  transition:
    box-shadow 0.2s,
    transform 0.1s;
}
button:hover:not(:disabled) {
  box-shadow: var(--glow);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button.ghost {
  border-color: var(--line);
  color: var(--fg);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--dim);
}
button[aria-pressed='true'] {
  background: var(--cyan);
  color: var(--on-cyan, #001015);
}
:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.stage {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
}
.stage video,
.stage img,
.stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.stage [hidden] {
  display: none;
}
.ph-bg {
  fill: var(--ph);
}
.ph-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}
.ph-dot {
  fill: var(--cyan);
  opacity: 0.6;
}
.ph-text {
  fill: var(--dim);
  font: 5px var(--mono);
  letter-spacing: 1px;
}
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font: 600 0.72rem var(--mono);
  letter-spacing: 0.08em;
  color: #19e3ff;
  text-shadow:
    0 0 4px #000,
    0 0 6px #19e3ff;
}
.hud span {
  position: absolute;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.55);
}
#hClock {
  bottom: 6px;
  left: 86px;
}
#hConn {
  top: 6px;
  right: 6px;
}
#hNight {
  bottom: 6px;
  left: 6px;
  color: #ffb000;
}
.radar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
}
.radar[hidden] {
  display: none;
}
.radar canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.netlabel {
  position: absolute;
  bottom: 12%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--mono, monospace);
  letter-spacing: 0.3em;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
}
.netlabel.bad {
  color: #ff2bd6;
  text-shadow: 0 0 8px #ff2bd6;
}
.radar.static .netlabel {
  position: static;
}
#box {
  position: absolute;
  border: 2px dashed #fff;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
}
.zoom {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.zoom input {
  width: min(240px, 60vw);
  accent-color: var(--cyan);
}
.head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.head {
  margin-bottom: 10px;
}
.head h2 {
  margin: 0;
}
.glass {
  grid-column: 1/-1;
}
.device {
  font: 600 0.8rem var(--mono);
  letter-spacing: 0.08em;
  color: var(--amber);
  margin: 2px 0 12px;
}
.eye {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 0.8rem var(--mono);
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
}
.lamp {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dim);
  transition:
    background 0.3s,
    box-shadow 0.3s;
}
.eye.has .lamp {
  background: #2cff9a;
  box-shadow: 0 0 10px #2cff9a;
  animation: pulse 2s ease-in-out infinite;
}
.eye.flip {
  animation: flip 0.5s ease-out;
}
@keyframes flip {
  0% {
    transform: scaleY(0.1);
    border-color: var(--magenta);
  }
  60% {
    transform: scaleY(1.15);
  }
  100% {
    transform: none;
  }
}
.gm {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.queue {
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  font: 0.85rem var(--mono);
  color: var(--dim);
}
input[type='text'] {
  font: inherit;
  padding: 6px 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg);
  width: 100%;
}
input[type='text']:disabled {
  opacity: 0.6;
}
:root[data-theme='light'] input[type='text'] {
  background: #fff;
}
.mono {
  font-family: var(--mono);
  font-size: 0.85rem;
  text-align: center;
  margin: 6px 0;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.kv dt {
  color: var(--dim);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.sliders {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.sliders input {
  width: 100%;
  accent-color: var(--cyan);
}
.sliders output {
  font: 0.85rem var(--mono);
  color: var(--amber);
}
.off {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.off li::after {
  content: '';
}
code {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: var(--mono);
}
footer {
  font-size: 0.85rem;
  color: var(--dim);
  padding-bottom: 24px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  body::after {
    display: none;
  }
}
.saybar select {
  font: inherit;
  min-height: 36px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg);
}
:root[data-theme='light'] .saybar select {
  background: #fff;
}
#sayStatus {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--amber);
}
h2 small,
h3 small {
  font: 400 0.72rem var(--sans, system-ui);
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--dim);
  margin-left: 6px;
}

/* One-screen deck: the Eye column (video, aim arrows, camera model, controls, say bar) beside a tabbed panel. Only a tab panel ever scrolls. */
.top {
  align-items: center;
  padding-top: 8px;
  width: 100%;
}
.strip code {
  padding: 0;
}
.title {
  min-width: 0;
}
.top .lede {
  margin: 2px 0;
  font-size: 0.9rem;
}
@media (min-width: 900px) {
  .top .lede {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
.top .device {
  margin: 0;
  font-size: 0.75rem;
}
h1 {
  font-size: 1.3rem;
}
code {
  white-space: nowrap;
}
.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  align-items: baseline;
  min-height: 26px;
}
.strip p {
  margin: 0;
  font-size: 0.9rem;
}
.demoline {
  color: var(--amber);
}
.demoline[hidden] {
  display: none;
}
#status {
  flex: 1 1 240px;
  min-width: 0;
  text-wrap: balance;
}
.linkish {
  background: none;
  border: 0;
  min-height: 24px;
  min-width: 0;
  padding: 0 2px;
  color: var(--cyan);
  text-decoration: underline;
  font: inherit;
  letter-spacing: 0;
}
.pill {
  font: 600 0.75rem var(--mono);
  letter-spacing: 0.06em;
  padding: 2px 12px;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--magenta);
  color: var(--magenta);
  background: transparent;
}
.pill.on {
  border-color: #2cff9a;
  color: #2cff9a;
}
:root[data-theme='light'] .pill.on {
  color: #006b3a;
  border-color: #006b3a;
}
.deckgrid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin: 6px 0 14px;
}
.eyepanel {
  padding: 10px 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.eyepanel .head {
  margin-bottom: 6px;
  gap: 4px 12px;
}
.eyepanel .head h2 {
  margin-right: auto;
}
.pose {
  margin: 0;
  font: 600 0.8rem var(--mono);
  color: var(--amber);
  white-space: nowrap;
}
.eyepanel .head button {
  min-height: 28px;
  padding: 2px 10px;
  font-size: 0.8rem;
}
.stagewrap {
  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
  flex: 1 1 auto;
}
.stage {
  width: min(100cqw, 100cqh * 16 / 9);
}
.pad button {
  position: absolute;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, 0.5);
  color: var(--cyan);
  border-color: var(--cyan);
  opacity: 0.6;
  transition: opacity 0.2s;
}
.pad button:hover:not(:disabled),
.pad button:focus-visible {
  opacity: 1;
}
.pad button:disabled {
  opacity: 0.28;
  color: var(--cyan);
  border-color: var(--cyan);
}
.pad .up {
  top: 10px;
  left: 50%;
  margin-left: -22px;
}
.pad .down {
  bottom: 10px;
  left: 50%;
  margin-left: -22px;
}
.pad .left {
  left: 10px;
  top: 50%;
  margin-top: -22px;
}
.pad .right {
  right: 10px;
  top: 50%;
  margin-top: -22px;
}
#model {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: min(22%, 140px);
  height: auto;
  aspect-ratio: 240/200;
  cursor: grab;
  touch-action: none;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.controls {
  gap: 6px 14px;
  margin: 8px 0 4px;
  justify-content: center;
}
.controls .check {
  font-weight: 600;
  white-space: nowrap;
}
.dim {
  color: var(--dim);
  font-weight: 400;
}
.controls .zoom {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  flex-direction: row;
}
.controls .zoom input {
  width: 120px;
}
.saybar {
  gap: 6px;
  margin: 2px auto 0;
  width: 100%;
  max-width: 900px;
}
.saybar h3 {
  margin: 0;
}
.saybar h3 small {
  margin-left: 6px;
}
.saybar select {
  font: inherit;
  min-height: 36px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--fg);
}
:root[data-theme='light'] .saybar select {
  background: #fff;
}
.sayrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
}
.sayrow .grow {
  flex: 1 1 220px;
}
.lvl {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.lvl input {
  width: 140px;
  accent-color: var(--cyan);
}
.lvl output {
  font: 0.85rem var(--mono);
  color: var(--amber);
}
#sayStatus {
  flex: 1 1 160px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--amber);
}
.sayopts summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 0.85rem;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.tabs {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
[role='tablist'] {
  display: flex;
  border-bottom: 1px solid var(--line);
}
[role='tab'] {
  flex: 1 1 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--dim);
  min-height: 40px;
  padding: 4px 4px;
  font-size: 0.72rem;
  letter-spacing: 0;
  white-space: nowrap;
}
[role='tab'][aria-selected='true'] {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  background: rgba(25, 227, 255, 0.08);
}
[role='tabpanel'] {
  padding: 12px 14px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
[role='tabpanel'][hidden] {
  display: none;
}
[role='tabpanel'] h2 small,
.eyepanel h2 small {
  margin-left: 6px;
}
.tabs .sliders,
.tabs .gm {
  grid-template-columns: 1fr;
}
.kv {
  grid-template-columns: max-content 1fr;
}
@media (min-width: 900px) {
  body {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  .deckgrid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 360px;
    margin: 6px 0 12px;
  }
  .eyepanel {
    min-height: 0;
  }
}
@media (min-width: 900px) and (max-height: 760px) {
  .top .lede {
    display: none;
  }
  .controls {
    margin: 4px 0 2px;
  }
}
@media (max-width: 899px) {
  .top .lede {
    font-size: 0.82rem;
    line-height: 1.3;
  }
  .stage {
    width: 100%;
  }
  .stagewrap {
    container-type: normal;
    display: block;
  }
  .eyepanel .head .eye {
    display: none;
  }
  .controls {
    justify-content: flex-start;
    gap: 6px 10px;
  }
  .controls button {
    padding: 2px 8px;
  }
  [role='tabpanel'] {
    overflow: visible;
  }
}
.tabs .sliders label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.tabs .sliders label input {
  flex: 1 1 auto;
  min-width: 0;
}
.tabs .sliders output {
  min-width: 2ch;
}
.tabs .sliders {
  gap: 4px;
}

#hRec {
  top: 6px;
  right: 6px;
  color: #ff4d5e;
  font-weight: 700;
}
#hRec[hidden] {
  display: none;
}
#hRec i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff2b3d;
  animation: recblink 1s steps(2, start) infinite;
}
@keyframes recblink {
  50% {
    opacity: 0.1;
  }
}
@media (prefers-reduced-motion: reduce) {
  #hRec i {
    animation: none;
  }
}
#rec[aria-pressed='true'] {
  background: #ff2b3d;
  color: #fff;
}
.tapelist {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.tapelist li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--line, rgba(25, 227, 255, 0.3));
  padding: 0.35rem;
}
.tapelist img,
.tapelist video {
  width: 96px;
  height: 54px;
  object-fit: cover;
  background: #000;
}
.tapelist .row {
  margin: 0.25rem 0 0;
  gap: 0.35rem;
}
.tapelist button {
  padding: 0.2rem 0.5rem;
  min-height: 28px;
}

.range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--dim);
}
.range[hidden] {
  display: none;
}
.rbar {
  --at: 50%;
  position: relative;
  width: 44px;
  height: 6px;
  background: rgba(25, 227, 255, 0.25);
  border-radius: 3px;
}
.rbar i {
  position: absolute;
  top: -2px;
  left: var(--at);
  width: 4px;
  height: 10px;
  margin-left: -2px;
  background: #ffb000;
}
#limitsBar {
  width: 100%;
}

/* Flatlined: the last frame stays on screen as a dead feed. */
.stage.flat #snap,
.stage.flat #video {
  filter: grayscale(1) brightness(0.75) contrast(1.1);
  transition: filter 0.8s ease;
}
.stage #snap,
.stage #video {
  transition: filter 0.4s ease;
}

/* SIGNAL LOST bar over the last known frame while flatlined. */
.lastbar {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.82);
  color: var(--amber, #ffb000);
  font-family: var(--mono, monospace);
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
}
.lastbar strong {
  color: var(--magenta, #ff2bd6);
}

.stills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 0.9rem var(--mono);
}
.stills select {
  font: 600 0.9rem var(--mono);
  min-height: 36px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--cyan);
  background: var(--btn);
  color: var(--cyan);
}
.stills select:disabled {
  opacity: 0.5;
}

/* An arrow at the estimated wall: still pressable, just flagged. */
.pad button.near-wall {
  border-color: var(--amber, #ffb000);
  color: var(--amber, #ffb000);
}

/* Saved shots: a strip of keys right under the picture and exactly as wide
   (app.js sets the width), like a camera controller's preset keys. Labels:
   numbers (compact, one row even on a phone), names, or pictures. */
.keys {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 3px;
  max-width: 100%;
  margin: 4px auto 0;
}
.keys button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 28px;
  padding: 1px 2px;
  overflow: hidden;
  line-height: 1.1;
}
.keys b {
  font: 700 0.85rem var(--mono);
}
.keys span {
  display: none;
  max-width: 100%;
  overflow: hidden;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}
.keys.names span {
  display: block;
}
.keys.names button {
  min-height: 38px;
}
.keys.names button:not(.has):not(.set):not(.all) span {
  color: var(--dim);
  font-style: italic;
}
.keys.pics button[data-slot] {
  aspect-ratio: 16/9;
  min-height: 0;
  background-size: cover;
  background-position: center;
}
.keys.pics button[data-slot] b {
  position: absolute;
  left: 2px;
  top: 1px;
  padding: 0 3px;
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.6);
}
.keys button.at {
  box-shadow: var(--glow);
  border-color: var(--cyan);
  background-color: rgba(25, 227, 255, 0.18);
}
.keys .set[aria-pressed='true'],
.keys.setting button {
  color: var(--amber);
  border-color: var(--amber);
}
@media (max-width: 640px) {
  .keys.names,
  .keys.pics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Naming a saved shot: takes the strip's place, so the eyes stay put. */
.shotform {
  display: flex;
  max-width: 100%;
  margin-inline: auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  min-height: 40px;
}
.shotform[hidden] {
  display: none;
}
.shotform label {
  color: var(--amber);
  font: 600 0.8rem var(--mono);
}
.shotform input {
  flex: 1 1 10em;
  min-width: 0;
}
.keys[hidden] {
  display: none;
}

/* All nine shots: a 3 by 3 grid over the picture, filled as the camera
   visits each one on the shortest route. */
.shotgrid {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
  background: #000;
}
.shotgrid[hidden] {
  display: none;
}
.shotgrid > button[data-cell] {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: var(--ph);
  border: 1px solid var(--line);
}
.shotgrid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shotgrid span {
  position: absolute;
  left: 3px;
  bottom: 2px;
  max-width: calc(100% - 6px);
  overflow: hidden;
  padding: 0 4px;
  font: 600 0.7rem var(--mono);
  color: var(--cyan);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.6);
}
.shotgrid > button.now {
  border-color: var(--amber);
  box-shadow: inset 0 0 0 2px var(--amber);
}
.gridclose {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
}

/* Night vision tint: the camera's infrared picture is gray; a color layer
   over it (blend mode color keeps the brightness) shows at a glance that the
   view is infrared. Chosen in Deck: red, green, blue, custom or none. */
.tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: color;
  background: var(--tint, transparent);
  display: none;
}
.stage.ir:not(.flat) .tint {
  display: block;
}
.shotgrid > button.ir.fresh::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: color;
  background: var(--tint, transparent);
}
/* Remembered pictures wait in gray until the fresh ones arrive in color. */
.shotgrid > button:not(.fresh) img {
  filter: grayscale(1) brightness(0.7);
}
.shotgrid > button.fresh img {
  animation: gj-fresh 0.5s ease;
}
@keyframes gj-fresh {
  from {
    filter: grayscale(1) brightness(1.6);
  }
}
@media (prefers-reduced-motion: reduce) {
  .shotgrid > button.fresh img {
    animation: none;
  }
}

/* A question from an agent (POST /api/ask): over the bottom of the picture,
   with a key per choice; spoken or pressed, the first answer wins. */
.askbar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 6;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid var(--amber);
  border-radius: 4px;
}
.askbar[hidden] {
  display: none;
}
.askbar p {
  margin: 0 0 6px;
  color: var(--amber);
  font: 600 0.85rem var(--mono);
}
.askchoices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.askchoices input {
  flex: 1 1 8em;
  min-width: 0;
}

/* The sphere view over the picture: three.js canvas, a flat overlay for the reticle, a bar of buttons. */
.sphereview {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #0b0f14;
  cursor: grab;
  touch-action: none;
}
.sphereview:focus-visible {
  outline: 2px solid var(--cyan, #19e3ff);
  outline-offset: -3px;
}
.sphereview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.spherebar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}
.spherebar button {
  min-width: 28px;
  min-height: 28px;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: rgba(8, 12, 18, 0.82);
  color: #e8f6ff;
  border: 1px solid rgba(25, 227, 255, 0.6);
  border-radius: 3px;
  cursor: pointer;
}
.spherebar button:focus-visible {
  outline: 2px solid #ffb000;
}
.spherenote {
  position: absolute;
  left: 6px;
  bottom: 6px;
  margin: 0;
  padding: 2px 6px;
  font-size: 0.72rem;
  color: #e8f6ff;
  background: rgba(8, 12, 18, 0.7);
  border-radius: 3px;
}
.spherenote:empty {
  display: none;
}

/* The strip scan panel: the panorama growing strip by strip, with its controls. */
.stripview {
  /* a band along the bottom, so the sphere above stays in view and can be
     dragged while the strips come in */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  z-index: 7;
  background: rgba(11, 15, 20, 0.92);
  border-top: 1px solid var(--line);
  touch-action: pan-y;
  cursor: grab;
}
.stripview:focus-visible {
  outline: 2px solid var(--cyan, #19e3ff);
  outline-offset: -3px;
}
.stripview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.stripbar {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 0.75rem;
  color: #e8f6ff;
}
.stripbar button,
.stripbar select {
  min-height: 28px;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: rgba(8, 12, 18, 0.82);
  color: #e8f6ff;
  border: 1px solid rgba(25, 227, 255, 0.6);
  border-radius: 3px;
  cursor: pointer;
}
.stripbar button:disabled {
  opacity: 0.5;
  cursor: default;
}
.stripbar label {
  padding: 2px 6px;
  background: rgba(8, 12, 18, 0.7);
  border-radius: 3px;
}
.stripbar button:focus-visible,
.stripbar select:focus-visible,
.stripbar input:focus-visible {
  outline: 2px solid #ffb000;
}
.stripnote {
  position: absolute;
  left: 6px;
  bottom: 6px;
  margin: 0;
  padding: 2px 6px;
  font-size: 0.72rem;
  color: #e8f6ff;
  background: rgba(8, 12, 18, 0.7);
  border-radius: 3px;
}
.stripnote:empty {
  display: none;
}

/* Twelve keys on a phone: the three-letter ones shrink so SET, ALL and SPH do not touch. */
@media (max-width: 480px) {
  .keys b {
    font-size: 0.7rem;
  }
}
@media (max-width: 640px) {
  .stripview {
    height: 78%;
  }
}
