:root {
  --bg: #020503;
  --panel: #041009;
  --text: #aec7b2;
  --text-strong: #c7dccb;
  --muted: #607967;
  --faint: #314339;
  --accent: #7da886;
  --danger: #b7a39a;
  --line: rgba(174, 199, 178, 0.13);
  --shadow: rgba(0, 0, 0, 0.8);
  --font: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  min-height: var(--app-height, 100dvh);
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(76, 118, 86, 0.07), transparent 42%),
    linear-gradient(180deg, #020503 0%, #010201 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  min-height: var(--app-height, 100dvh);
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
}

#shell {
  width: min(920px, 100%);
  min-height: min(760px, calc(var(--app-height, 100dvh) - 7rem));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1.1rem, 3vw, 2.2rem);
  background: rgba(2, 8, 4, 0.78);
  border: 1px solid var(--line);
  box-shadow: 0 28px 90px var(--shadow), inset 0 0 45px rgba(74, 120, 82, 0.035);
  position: relative;
  overflow: hidden;
}

#shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.014) 0,
    rgba(255,255,255,0.014) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
  opacity: 0.34;
}

#shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.28) 100%);
}

#screen {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  max-height: calc(var(--app-height, 100dvh) - 12rem);
  padding-right: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

.entry {
  margin: 0 0 1.05rem 0;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: normal;
}

.entry.system { color: var(--muted); }
.entry.command { color: var(--accent); margin-bottom: 0.45rem; }
.entry.warning { color: var(--danger); }
.entry.choice { color: var(--text-strong); }
.entry.small { font-size: 0.92rem; color: var(--muted); }
.entry .caps { letter-spacing: 0.04em; }

#inputForm {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(174, 199, 178, 0.08);
}

#prompt { color: var(--accent); opacity: 0.9; }

#command {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
}

#command::selection, .entry::selection { background: rgba(125, 168, 134, 0.25); }

footer {
  position: fixed;
  right: 1rem;
  bottom: 0.85rem;
  z-index: 10;
}

button {
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}

button:hover, button:focus-visible {
  color: var(--text);
  border-bottom-color: var(--faint);
  outline: none;
}

#traceButton { font-size: 0.78rem; opacity: 0.62; }

#traceDialog {
  width: min(640px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  background: #030804;
  color: var(--text);
  padding: 0;
  box-shadow: 0 30px 110px var(--shadow);
}

#traceDialog::backdrop { background: rgba(0, 0, 0, 0.76); }

.dialog-inner { padding: 1.5rem; }
.dialog-inner h1 { font-size: 1rem; margin: 0 0 1rem 0; font-weight: 500; }
.dialog-inner p { line-height: 1.55; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.25rem; }
.dialog-actions button { padding: 0.45rem 0.65rem; border: 1px solid var(--faint); }
.noscript { position: fixed; left: 1rem; bottom: 1rem; color: var(--danger); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  body { padding: 0.55rem; align-items: stretch; justify-content: flex-start; }
  #shell {
    min-height: calc(var(--app-height, 100dvh) - 3.1rem);
    padding: 0.95rem;
  }
  #screen { max-height: calc(var(--app-height, 100dvh) - 7.2rem); padding-right: 0.1rem; }
  .entry { margin-bottom: 0.82rem; line-height: 1.52; }
  #inputForm { padding-top: 0.45rem; gap: 0.5rem; }
  footer { right: 0.75rem; bottom: 0.45rem; }
  body.typing #screen { max-height: calc(var(--app-height, 100dvh) - 6.7rem); }
}


.choice-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  margin: 0 0 1.05rem 0;
}

.choice-button {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: baseline;
  gap: 0.45rem;
  text-align: left;
  color: var(--text-strong);
  background: rgba(125, 168, 134, 0.025);
  border: 1px solid rgba(174, 199, 178, 0.08);
  border-radius: 0.18rem;
  padding: 0.38rem 0.5rem;
  line-height: 1.45;
}

.choice-button:hover,
.choice-button:focus-visible {
  color: var(--text);
  background: rgba(125, 168, 134, 0.055);
  border-color: rgba(174, 199, 178, 0.20);
  outline: none;
}

.choice-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.choice-number {
  color: var(--accent);
  opacity: 0.82;
}

.choice-label { min-width: 0; }

@media (hover: none), (pointer: coarse) {
  .choice-button {
    min-height: 2.35rem;
    padding: 0.48rem 0.55rem;
  }
}

#plainLink {
  font: inherit;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  opacity: 0.42;
  margin-right: 0.8rem;
}
#plainLink:hover, #plainLink:focus-visible { color: var(--text); opacity: 0.8; }
.entry.error { color: var(--danger); }
.choice-list { margin: 0 0 1.05rem 0; white-space: pre-wrap; color: var(--text-strong); }
.plain-form { display: flex; gap: 0.75rem; align-items: center; border-top: 1px solid rgba(174,199,178,0.08); padding-top: 0.75rem; }
.plain-form input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font: inherit; caret-color: var(--accent); }
.plain-form button { border: 1px solid var(--faint); padding: 0.35rem 0.6rem; }
.plain-meta { color: var(--muted); font-size: 0.8rem; margin-top: 1rem; }
.plain-meta a { color: var(--muted); }

.media-frame {
  margin: 0.35rem 0 1.35rem 0;
  border: 1px solid rgba(174,199,178,0.16);
  background: rgba(0,0,0,0.38);
  padding: 0.55rem;
  box-shadow: inset 0 0 28px rgba(125,168,134,0.035), 0 18px 60px rgba(0,0,0,0.35);
}

.breach-video {
  display: block;
  width: 100%;
  max-height: min(58vh, 520px);
  background: #000;
  border: 1px solid rgba(174,199,178,0.10);
}

.media-frame figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.media-frame.media-missing .breach-video {
  min-height: 10rem;
  background:
    linear-gradient(135deg, rgba(125,168,134,0.04), transparent),
    #000;
}

.media-link {
  display: inline-block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
  border-bottom: 1px dotted rgba(174,199,178,0.28);
}
.media-link:hover { color: var(--text); }
.media-status {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}
.media-frame.media-missing {
  border-color: rgba(205,116,116,0.28);
}
#command::placeholder {
  color: var(--muted);
  opacity: 0.38;
}

body[data-ds-tint="green"] .terminal-screen,
body[data-ds-tint="green"] .entry,
body[data-ds-tint="green"] .choice-button {
  text-shadow: 0 0 0.55rem rgba(125, 255, 155, 0.22);
}

body[data-ds-tint="black"] .terminal-screen {
  filter: saturate(0.82) brightness(0.94);
}

/* v1.2.1 UX layer: readable voices, quick nudges, shareable moments */
#quickBar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin: 0 0 0.55rem 0;
  min-height: 1.7rem;
}

#quickBar[hidden] { display: none; }

.quick-command {
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--muted);
  border: 1px solid rgba(174, 199, 178, 0.10);
  border-radius: 999px;
  padding: 0.26rem 0.54rem;
  background: rgba(125, 168, 134, 0.025);
}

.quick-command:hover,
.quick-command:focus-visible {
  color: var(--text-strong);
  border-color: rgba(174, 199, 178, 0.23);
  background: rgba(125, 168, 134, 0.06);
}

.entry.hint {
  color: var(--text-strong);
  border-left: 2px solid rgba(125, 168, 134, 0.42);
  padding-left: 0.85rem;
}

.entry.creature {
  color: var(--text-strong);
  text-shadow: 0 0 14px rgba(125, 168, 134, 0.055);
}

.entry.words,
.entry.archive {
  border-left: 1px solid rgba(174, 199, 178, 0.14);
  padding-left: 0.85rem;
  color: var(--text-strong);
}

.entry.swarm {
  color: #b7c7c0;
  border: 1px solid rgba(174, 199, 178, 0.12);
  border-left: 3px solid rgba(174, 199, 178, 0.30);
  padding: 0.78rem 0.9rem;
  background: linear-gradient(90deg, rgba(174, 199, 178, 0.035), transparent 70%);
  letter-spacing: 0.015em;
}

.entry.dark {
  color: #c9b9b2;
  border-left: 3px solid rgba(183, 163, 154, 0.36);
  padding-left: 0.9rem;
  background: linear-gradient(90deg, rgba(183, 163, 154, 0.035), transparent 72%);
}

.entry.memory {
  position: relative;
  margin: 1.15rem 0 1.2rem 0;
  padding: 0.9rem 1rem 2.45rem 1rem;
  color: var(--text-strong);
  border: 1px solid rgba(174, 199, 178, 0.19);
  background:
    linear-gradient(180deg, rgba(125, 168, 134, 0.06), rgba(125, 168, 134, 0.018)),
    rgba(2, 8, 4, 0.45);
  box-shadow: inset 0 0 24px rgba(125, 168, 134, 0.028);
}

.entry.memory::before {
  content: "saved moment";
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.copy-memory-button {
  position: absolute;
  right: 0.68rem;
  bottom: 0.55rem;
  font-size: 0.75rem;
  border: 1px solid rgba(174, 199, 178, 0.16);
  border-radius: 0.18rem;
  padding: 0.25rem 0.45rem;
  background: rgba(2, 8, 4, 0.65);
}

@media (max-width: 700px) {
  #quickBar { gap: 0.28rem; margin-bottom: 0.42rem; }
  .quick-command { font-size: 0.72rem; padding: 0.25rem 0.45rem; }
  .entry.memory { padding: 0.75rem 0.8rem 2.3rem 0.8rem; }
}

/* v1.5 Small Cultures layer retained in v2.0 */
.entry.diagnostic {
  color: #9fb7ae;
  border-left: 3px solid rgba(159, 183, 174, 0.28);
  padding: 0.68rem 0.9rem;
  background:
    linear-gradient(90deg, rgba(159, 183, 174, 0.040), transparent 78%),
    repeating-linear-gradient(180deg, rgba(255,255,255,0.010) 0, rgba(255,255,255,0.010) 1px, transparent 1px, transparent 5px);
  font-size: 0.94rem;
  letter-spacing: 0.018em;
}

.ghost-completion {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  max-width: min(34rem, 92vw);
  color: var(--muted);
  background: rgba(2, 8, 4, 0.90);
  border: 1px solid rgba(174,199,178,0.12);
  border-radius: 0.18rem;
  padding: 0.28rem 0.48rem;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0.88;
}

.ghost-completion::before {
  content: "autocomplete: ";
  color: var(--faint);
}

.ghost-completion.bad-suggestion {
  color: #c9b9b2;
  border-color: rgba(183, 163, 154, 0.24);
  text-decoration: line-through;
  opacity: 0.72;
}

.ghost-completion.error-suggestion {
  color: var(--danger);
  border-color: rgba(183, 163, 154, 0.34);
  text-decoration: none;
}

.ghost-completion.soft-suggestion {
  opacity: 0.52;
}

body.diagnostic-pulse #shell {
  box-shadow: 0 28px 90px var(--shadow), inset 0 0 60px rgba(174,199,178,0.065);
}

body.dark-pulse #shell {
  box-shadow: 0 28px 90px var(--shadow), inset 0 0 70px rgba(183,163,154,0.08);
}

body.terminal-error-flash #shell::before {
  opacity: 0.58;
  background: repeating-linear-gradient(
    to bottom,
    rgba(183,163,154,0.035) 0,
    rgba(183,163,154,0.035) 1px,
    transparent 1px,
    transparent 3px
  );
}

body.terminal-error-flash #prompt {
  color: var(--danger);
}

@media (prefers-reduced-motion: no-preference) {
  body.diagnostic-pulse #shell,
  body.dark-pulse #shell,
  body.terminal-error-flash #shell {
    transition: box-shadow 0.18s ease, filter 0.18s ease;
  }
  .entry.diagnostic {
    animation: diagnostic-arrive 0.28s ease-out;
  }
  @keyframes diagnostic-arrive {
    from { opacity: 0.55; transform: translateX(-0.22rem); }
    to { opacity: 1; transform: translateX(0); }
  }
}

@media (max-width: 700px) {
  .ghost-completion {
    left: 0;
    right: auto;
    max-width: 100%;
    font-size: 0.72rem;
  }
  .entry.diagnostic { font-size: 0.88rem; padding: 0.58rem 0.72rem; }
}

/* v2.0 Outside contact layer */
.entry.outside {
  color: #c7c4b8;
  border: 1px solid rgba(199, 196, 184, 0.15);
  border-left: 3px solid rgba(199, 196, 184, 0.42);
  padding: 0.82rem 0.92rem;
  background:
    linear-gradient(90deg, rgba(199, 196, 184, 0.045), transparent 72%),
    repeating-linear-gradient(180deg, transparent 0, transparent 1.35rem, rgba(199,196,184,0.018) 1.38rem);
  letter-spacing: 0.012em;
  text-shadow: 0 0 18px rgba(199, 196, 184, 0.04);
}

.entry.outside::before {
  content: "external interval";
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  .entry.outside { padding: 0.7rem 0.76rem; }
}

/* v2.1 Wireframe Aperture */
:root {
  --wire-line: #7da886;
  --wire-bright: #c7dccb;
  --wire-faint: rgba(125, 168, 134, 0.22);
  --wire-dark: #020503;
  --wire-warning: #b7a39a;
}

#modeButton {
  font-size: 0.78rem;
  opacity: 0.62;
  margin-right: 0.8rem;
}

.mode-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 30%, rgba(80, 125, 91, 0.11), transparent 42%),
    rgba(0, 2, 1, 0.94);
  backdrop-filter: blur(4px);
}

.mode-gate[hidden] { display: none; }

.mode-gate-panel {
  width: min(820px, 100%);
  border: 1px solid rgba(174, 199, 178, 0.20);
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.012) 0, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 4px),
    rgba(2, 8, 4, 0.97);
  box-shadow: 0 34px 120px rgba(0,0,0,0.86), inset 0 0 70px rgba(125,168,134,0.025);
  padding: clamp(1.1rem, 4vw, 2.2rem);
}

.boot-kicker {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.13em;
}

.mode-gate h1 {
  margin: 0 0 0.7rem;
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 500;
  color: var(--text-strong);
}

.mode-gate-copy {
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 1.4rem;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.mode-option {
  min-height: 10rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 1rem;
  color: var(--text);
  border: 1px solid rgba(174,199,178,0.15);
  background: rgba(125,168,134,0.025);
}

.mode-option:first-child {
  background:
    linear-gradient(135deg, rgba(125,168,134,0.07), transparent 72%),
    rgba(125,168,134,0.025);
}

.mode-option:hover,
.mode-option:focus-visible {
  color: var(--text-strong);
  border-color: rgba(174,199,178,0.42);
  background: rgba(125,168,134,0.075);
  outline: none;
}

.mode-option-title {
  font-size: 1.05rem;
  color: var(--text-strong);
}

.mode-option-copy {
  line-height: 1.5;
  color: var(--muted);
}

.mode-option-status {
  margin-top: auto;
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  color: var(--accent);
}

.mode-gate-small {
  margin: 1.25rem 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.visual-viewport {
  position: relative;
  z-index: 1;
  min-height: 32rem;
  overflow: hidden;
  border: 1px solid rgba(174,199,178,0.14);
  background: #020503;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.72);
  isolation: isolate;
}

.visual-viewport[hidden] { display: none; }

#wireframeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.visual-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.018), transparent 2%, transparent 98%, rgba(255,255,255,0.018)),
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.012) 0, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: screen;
}

.visual-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 54%, rgba(0,0,0,0.54) 100%);
}

.visual-hud {
  position: absolute;
  inset: 0.72rem 0.82rem auto 0.82rem;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
}

.visual-room-label {
  display: block;
  color: var(--wire-bright);
  font-size: clamp(0.8rem, 1.4vw, 1rem);
  letter-spacing: 0.12em;
  text-shadow: 0 0 1rem rgba(125,168,134,0.25);
}

.visual-zone-label {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.visual-signal-label {
  color: var(--wire-warning);
  font-size: 0.67rem;
  letter-spacing: 0.1em;
  border: 1px solid rgba(183,163,154,0.24);
  padding: 0.28rem 0.45rem;
  background: rgba(2,5,3,0.72);
}

.visual-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 1.25rem;
  height: 1.25rem;
  transform: translate(-50%, -50%);
  opacity: 0.24;
  pointer-events: none;
}

.visual-reticle::before,
.visual-reticle::after {
  content: "";
  position: absolute;
  background: var(--wire-line);
}

.visual-reticle::before { left: 50%; top: 0; width: 1px; height: 100%; }
.visual-reticle::after { top: 50%; left: 0; height: 1px; width: 100%; }

.visual-instruction {
  position: absolute;
  left: 0.75rem;
  bottom: 0.55rem;
  z-index: 6;
  color: var(--faint);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.visual-hotspots {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.visual-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  max-width: min(13rem, 28vw);
  padding: 0.25rem;
  border: none;
  color: var(--wire-line);
  background: transparent;
  text-align: center;
  pointer-events: auto;
  text-shadow: 0 0 0.8rem rgba(125,168,134,0.35);
}

.visual-hotspot:hover,
.visual-hotspot:focus-visible {
  color: var(--wire-bright);
  border: none;
  outline: 1px solid rgba(174,199,178,0.23);
  outline-offset: 0.25rem;
}

.hotspot-marker {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(2,5,3,0.72);
  font-size: 0.82rem;
  line-height: 1;
}

.visual-exit .hotspot-marker {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0;
  transform: rotate(45deg);
}

.visual-exit .hotspot-marker::first-letter { transform: rotate(-45deg); }

.hotspot-label {
  max-width: 13rem;
  color: inherit;
  background: rgba(2,5,3,0.72);
  border: 1px solid rgba(174,199,178,0.10);
  padding: 0.22rem 0.36rem;
  font-size: clamp(0.62rem, 1vw, 0.74rem);
  line-height: 1.25;
}

body[data-access-mode="visual"] {
  align-items: stretch;
  justify-content: center;
  padding: clamp(0.45rem, 1.4vw, 1.2rem);
}

body[data-access-mode="visual"] #shell {
  width: min(1440px, 100%);
  min-height: calc(var(--app-height, 100dvh) - 3.2rem);
  height: calc(var(--app-height, 100dvh) - 3.2rem);
  max-height: calc(var(--app-height, 100dvh) - 3.2rem);
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(320px, 0.72fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0.72rem 0.9rem;
  padding: clamp(0.7rem, 1.5vw, 1.15rem);
  justify-content: stretch;
}

body[data-access-mode="visual"] #visualViewport {
  display: block;
  grid-column: 1;
  grid-row: 1 / 4;
  min-height: 0;
  height: 100%;
}

body[data-access-mode="visual"] #screen {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  max-height: none;
  padding: 0.55rem 0.55rem 0 0.2rem;
  mask-image: linear-gradient(to bottom, transparent 0, black 3rem, black 100%);
}

body[data-access-mode="visual"] #quickBar {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  padding: 0.2rem 0;
}

body[data-access-mode="visual"] #inputForm {
  grid-column: 2;
  grid-row: 3;
}

body[data-access-mode="visual"] .entry {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.78rem;
}

body[data-access-mode="visual"] .choice-buttons {
  display: none;
}

body[data-access-mode="visual"] footer { z-index: 20; }

body[data-ds-tint="green"] {
  --wire-line: #7fe79b;
  --wire-bright: #c8ffd4;
  --wire-faint: rgba(127,231,155,0.22);
}

body[data-ds-tint="black"] {
  --wire-line: #9a9f9b;
  --wire-bright: #c4c7c5;
  --wire-faint: rgba(154,159,155,0.19);
}

@media (prefers-reduced-motion: reduce) {
  .visual-hotspot,
  .mode-option { transition: none; }
}

@media (max-width: 900px) {
  body[data-access-mode="visual"] {
    padding: 0.4rem;
  }

  body[data-access-mode="visual"] #shell {
    min-height: calc(var(--app-height, 100dvh) - 2.9rem);
    height: calc(var(--app-height, 100dvh) - 2.9rem);
    max-height: calc(var(--app-height, 100dvh) - 2.9rem);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(17rem, 52vh) minmax(7rem, 1fr) auto auto;
    gap: 0.45rem;
    padding: 0.5rem;
  }

  body[data-access-mode="visual"] #visualViewport {
    grid-column: 1;
    grid-row: 1;
    min-height: 17rem;
  }

  body[data-access-mode="visual"] #screen {
    grid-column: 1;
    grid-row: 2;
    max-height: none;
    padding: 0.35rem 0.3rem 0;
    mask-image: linear-gradient(to bottom, transparent 0, black 1.6rem, black 100%);
  }

  body[data-access-mode="visual"] #quickBar { grid-column: 1; grid-row: 3; }
  body[data-access-mode="visual"] #inputForm { grid-column: 1; grid-row: 4; }
  body[data-access-mode="visual"] .entry { font-size: 0.82rem; line-height: 1.42; }

  .visual-instruction { display: none; }
  .hotspot-label { max-width: 9rem; font-size: 0.61rem; }
  .visual-hotspot { max-width: 10rem; }
}

@media (max-width: 650px) {
  .mode-options { grid-template-columns: 1fr; }
  .mode-option { min-height: 7.7rem; }
  .mode-gate-panel { max-height: calc(var(--app-height, 100dvh) - 1.2rem); overflow-y: auto; }
  .visual-hud { inset: 0.48rem 0.52rem auto 0.52rem; }
  .visual-room-label { font-size: 0.72rem; }
  .visual-zone-label, .visual-signal-label { font-size: 0.56rem; }
  .hotspot-label { display: block; max-width: 7.2rem; font-size: 0.55rem; padding: 0.16rem 0.25rem; }
  .hotspot-marker { background: rgba(2,5,3,0.88); }
}

/* -------------------------------------------------------------------------
   v2.2.0 — Walkable Aperture
   ------------------------------------------------------------------------- */

:root {
  --wire-wall: #07110a;
  --transcript-bg: rgba(2, 7, 4, 0.94);
}

.transcript-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.transcript-panel #screen {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.transcript-toggle,
.latest-button {
  display: none;
}

#wireframeCanvas {
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

.visual-viewport.pointer-locked #wireframeCanvas { cursor: none; }

.visual-context {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 1.05rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: min(90%, 34rem);
  padding: 0.34rem 0.46rem 0.34rem 0.66rem;
  border: 1px solid rgba(174,199,178,0.12);
  background: rgba(2,5,3,0.72);
  color: var(--muted);
  font-size: clamp(0.58rem, 0.9vw, 0.7rem);
  letter-spacing: 0.08em;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(3px);
}

.visual-context button {
  flex: 0 0 auto;
  min-width: 3.2rem;
  padding: 0.28rem 0.46rem;
  border: 1px solid rgba(174,199,178,0.22);
  color: var(--wire-bright);
  background: rgba(125,168,134,0.05);
  pointer-events: auto;
}

.visual-context button:disabled {
  opacity: 0.28;
  cursor: default;
}

.visual-viewport.has-focus .visual-reticle { opacity: 0.84; }
.visual-viewport.has-focus .visual-context {
  color: var(--wire-bright);
  border-color: rgba(174,199,178,0.3);
  box-shadow: 0 0 1.4rem rgba(125,168,134,0.08);
}

.touch-key { display: none; }
.visual-touch-controls { display: none; }

body[data-access-mode="visual"] .transcript-panel {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  padding: 0.45rem 0.45rem 0 0.15rem;
  border-left: 1px solid rgba(174,199,178,0.08);
  background: linear-gradient(90deg, rgba(2,5,3,0.45), rgba(2,5,3,0.78));
}

body[data-access-mode="visual"] .transcript-panel #screen {
  padding: 0.25rem 0.5rem 0.25rem 0.5rem;
  mask-image: none;
}

body[data-access-mode="visual"] #screen {
  grid-column: auto;
  grid-row: auto;
  padding: 0;
  mask-image: none;
}

body[data-access-mode="visual"] #quickBar {
  overflow-x: auto;
  scrollbar-width: none;
}
body[data-access-mode="visual"] #quickBar::-webkit-scrollbar { display: none; }

@media (hover: none), (pointer: coarse) {
  .desktop-key { display: none; }
  .touch-key { display: inline; }
  .visual-touch-controls {
    position: absolute;
    inset: 0;
    z-index: 7;
    display: block;
    pointer-events: none;
  }
  .touch-move-pad {
    position: absolute;
    left: max(0.7rem, env(safe-area-inset-left));
    bottom: max(4.5rem, calc(env(safe-area-inset-bottom) + 4rem));
    width: clamp(5.2rem, 22vw, 7.2rem);
    aspect-ratio: 1;
    pointer-events: auto;
    touch-action: none;
  }
  .touch-move-ring {
    position: absolute;
    inset: 0;
    border: 1px solid rgba(174,199,178,0.22);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(125,168,134,0.06), rgba(2,5,3,0.34) 70%);
    box-shadow: inset 0 0 1.5rem rgba(0,0,0,0.45);
  }
  .touch-move-ring::before,
  .touch-move-ring::after {
    content: "";
    position: absolute;
    left: 50%; top: 50%;
    background: rgba(174,199,178,0.11);
    transform: translate(-50%, -50%);
  }
  .touch-move-ring::before { width: 1px; height: 74%; }
  .touch-move-ring::after { width: 74%; height: 1px; }
  .touch-move-knob {
    position: absolute;
    left: 50%; top: 50%;
    width: 42%;
    aspect-ratio: 1;
    margin: -21% 0 0 -21%;
    border: 1px solid rgba(199,220,203,0.48);
    border-radius: 50%;
    background: rgba(125,168,134,0.13);
    box-shadow: 0 0 1rem rgba(125,168,134,0.12);
    will-change: transform;
  }
  .touch-look-zone {
    position: absolute;
    right: 0;
    top: 3rem;
    bottom: 3.9rem;
    width: 58%;
    pointer-events: auto;
    touch-action: none;
  }
  .touch-look-zone span {
    position: absolute;
    right: max(0.7rem, env(safe-area-inset-right));
    bottom: 1rem;
    color: rgba(174,199,178,0.22);
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
  }
  .visual-context {
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    max-width: 56%;
    font-size: 0.56rem;
  }
}

@media (max-width: 900px) {
  body[data-access-mode="visual"] {
    overflow: hidden;
    min-height: var(--app-height, 100dvh);
  }

  body[data-access-mode="visual"] #shell {
    position: relative;
    display: block;
    width: 100%;
    min-height: calc(var(--app-height, 100dvh) - 2.7rem);
    height: calc(var(--app-height, 100dvh) - 2.7rem);
    max-height: calc(var(--app-height, 100dvh) - 2.7rem);
    padding: 0.35rem;
    overflow: hidden;
  }

  body[data-access-mode="visual"] #visualViewport {
    position: absolute;
    inset: 0.35rem 0.35rem 3.35rem 0.35rem;
    width: auto;
    height: auto;
    min-height: 0;
  }

  body[data-access-mode="visual"] #inputForm {
    position: absolute;
    z-index: 24;
    left: 0.45rem;
    right: 0.45rem;
    bottom: max(0.25rem, env(safe-area-inset-bottom));
    height: 2.7rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid rgba(174,199,178,0.12);
    background: rgba(2,7,4,0.94);
    backdrop-filter: blur(5px);
  }

  body[data-access-mode="visual"] #quickBar {
    display: none;
  }

  body[data-access-mode="visual"] .transcript-panel {
    position: absolute;
    z-index: 20;
    left: 0.55rem;
    right: 0.55rem;
    bottom: calc(3.35rem + max(0rem, env(safe-area-inset-bottom)));
    height: min(34vh, 17rem);
    min-height: 3rem;
    padding: 0;
    border: 1px solid rgba(174,199,178,0.18);
    background: var(--transcript-bg);
    box-shadow: 0 -0.8rem 2rem rgba(0,0,0,0.42);
    transition: height 170ms ease, transform 170ms ease;
    backdrop-filter: blur(7px);
  }

  body[data-access-mode="visual"].transcript-collapsed .transcript-panel {
    height: 3.1rem;
  }

  body[data-access-mode="visual"].transcript-expanded .transcript-panel {
    height: min(74vh, calc(var(--app-height, 100dvh) - 5rem));
  }

  .transcript-toggle {
    position: relative;
    z-index: 2;
    display: flex;
    flex: 0 0 2.45rem;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    border: 0;
    border-bottom: 1px solid rgba(174,199,178,0.1);
    color: var(--muted);
    background: rgba(125,168,134,0.025);
    font-size: 0.63rem;
    letter-spacing: 0.11em;
  }

  .transcript-chevron { color: var(--accent); }
  .transcript-unread {
    min-width: 1.35rem;
    padding: 0.12rem 0.28rem;
    border: 1px solid rgba(174,199,178,0.18);
    color: var(--text-strong);
    background: rgba(125,168,134,0.08);
    font-size: 0.58rem;
  }

  body[data-access-mode="visual"].transcript-collapsed .transcript-panel #screen {
    overflow: hidden;
    opacity: 0.62;
    padding-top: 0.2rem;
  }

  body[data-access-mode="visual"] .transcript-panel #screen {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.35rem 0.55rem 0.8rem;
    scroll-padding-bottom: 2.5rem;
  }

  .latest-button {
    position: absolute;
    z-index: 4;
    right: 0.55rem;
    bottom: 0.45rem;
    display: block;
    padding: 0.25rem 0.45rem;
    border: 1px solid rgba(174,199,178,0.2);
    color: var(--text-strong);
    background: rgba(2,7,4,0.92);
    font-size: 0.62rem;
  }
  .latest-button[hidden] { display: none; }

  body[data-access-mode="visual"] .entry {
    font-size: 0.82rem;
    line-height: 1.46;
  }

  body[data-access-mode="visual"] .visual-instruction {
    display: none;
  }

  body[data-access-mode="visual"] footer {
    bottom: max(0.25rem, env(safe-area-inset-bottom));
  }
}

@media (max-width: 650px) {
  body[data-access-mode="visual"] #visualViewport {
    inset: 0.25rem 0.25rem 3.25rem 0.25rem;
  }
  .visual-hud { inset: 0.48rem 0.52rem auto 0.52rem; }
  .visual-room-label { max-width: 72vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .visual-signal-label { max-width: 36vw; text-align: right; }
  .visual-context { max-width: 58%; bottom: 0.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-access-mode="visual"] .transcript-panel { transition: none; }
}
