:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #020500;
  --void: #000;
  --ink: #9cff80;
  --muted: rgba(156, 255, 128, 0.66);
  --faint: rgba(156, 255, 128, 0.13);
  --line: rgba(156, 255, 128, 0.34);
  --blue: #69f7ff;
  --hot: #ffb000;
  --good: #00ff66;
  --warm: #ffbf00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  text-shadow: 0 0 8px rgba(156, 255, 128, 0.22);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(156, 255, 128, 0.05) 0,
      rgba(156, 255, 128, 0.05) 1px,
      transparent 1px,
      transparent 9px
    );
  mix-blend-mode: screen;
  opacity: 0.42;
}

button,
textarea,
select {
  font: inherit;
}

button,
select,
textarea {
  border-radius: 0;
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.mast {
  min-height: 50px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: #000;
}

.brand,
.model-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 22px;
  border: 1px solid var(--line);
  object-fit: cover;
  filter: grayscale(1) contrast(1.6) sepia(1) hue-rotate(54deg) saturate(2);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 0.92rem;
  font-weight: 680;
  letter-spacing: 0;
}

h2,
label,
.role,
dt,
.meta,
.mirror-panel h3 {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 680;
  letter-spacing: 0;
  text-transform: none;
}

#status {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

select {
  max-width: min(50vw, 420px);
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0 8px;
}

option {
  background: var(--bg);
  color: var(--ink);
}

.surface {
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.rail {
  min-width: 0;
  border-right: 1px solid var(--line);
  overflow: auto;
  background: #000;
}

.block {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.block h2 {
  margin-bottom: 12px;
}

pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mode-list,
.preset-list,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-actions {
  margin-top: 10px;
}

button {
  min-height: 30px;
  border: 1px solid var(--line);
  background: #000;
  color: var(--ink);
  padding: 4px 8px;
  cursor: pointer;
}

button:hover,
button.active {
  background: rgba(156, 255, 128, 0.16);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

button:disabled {
  cursor: wait;
  opacity: 0.48;
}

.mode,
.preset,
.quiet {
  min-width: 0;
  text-align: left;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--faint);
  padding-bottom: 8px;
}

dd {
  margin: 0;
  font: 0.96rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(320px, 48vh) minmax(220px, 1fr);
  overflow: hidden;
  background: var(--bg);
}

.stage-head {
  padding: 10px 12px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.statement {
  color: var(--ink);
  font-size: clamp(0.9rem, 1.5vw, 1.35rem);
  font-weight: 680;
  line-height: 1.1;
}

.substatement {
  max-width: 460px;
  color: var(--muted);
  font: 0.72rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: right;
}

.composer {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px 12px 54px;
  border-bottom: 1px solid var(--line);
}

.horizon-field {
  position: relative;
  width: 100%;
  height: clamp(280px, 43vh, 520px);
  min-height: 0;
  cursor: text;
  isolation: isolate;
  border: 1px solid var(--line);
}

.horizon-field.is-focused {
  outline: 1px solid var(--warm);
  outline-offset: 0;
}

.capture-input {
  position: absolute;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  opacity: 0.01;
  padding: 0;
  overflow: hidden;
}

.capture-input:focus {
  outline: 0;
}

.horizon-visual {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 0;
  background:
    linear-gradient(rgba(156, 255, 128, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(156, 255, 128, 0.035) 1px, transparent 1px),
    #000;
  background-size: 18px 18px;
}

.orbit-line,
.void,
.capture-placeholder {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.orbit-line {
  border: 1px dotted var(--faint);
  border-radius: 50%;
  pointer-events: none;
}

.orbit-line-outer {
  width: 88%;
  height: 58%;
}

.orbit-line-mid {
  width: 66%;
  height: 42%;
  border-color: rgba(139, 189, 255, 0.18);
}

.orbit-line-inner {
  width: 42%;
  height: 28%;
  border-color: rgba(255, 211, 108, 0.2);
}

.void {
  z-index: 5;
  width: clamp(120px, 18vw, 210px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--void);
  border: 1px dashed rgba(156, 255, 128, 0.22);
  box-shadow:
    0 0 0 6px rgba(0, 0, 0, 0.72),
    0 0 18px rgba(156, 255, 128, 0.12);
}

.horizon-caret {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 34%;
  transform: translate(-50%, -50%);
  background: var(--ink);
  animation: caretBlink 1s steps(2, end) infinite;
}

.capture-placeholder {
  z-index: 4;
  width: 100%;
  height: 100%;
  color: rgba(156, 255, 128, 0.48);
  font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  pointer-events: none;
  text-align: center;
}

.capture-placeholder span {
  position: absolute;
  left: 50%;
  width: min(72vw, 500px);
  transform: translateX(-50%);
}

.capture-placeholder span:first-child {
  top: 11%;
}

.capture-placeholder span:last-child {
  bottom: 11%;
}

.accretion-fragments,
.token-field,
.band-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.fragment,
.token-body,
.redaction-band {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.fragment {
  z-index: 1;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(247, 251, 255, 0.26);
  font-size: clamp(0.6rem, 1vw, 0.78rem);
  animation: fragmentDrift 8s ease-in-out var(--fragment-delay) infinite;
}

.token-body {
  z-index: 7;
  max-width: min(28ch, 34vw);
  overflow: visible;
  color: var(--ink);
  font-size: clamp(0.74rem, 1.25vw, 1.04rem);
  line-height: 1;
  text-shadow: 0 0 10px rgba(156, 255, 128, 0.26);
  transform-origin: center;
  transition:
    left 260ms ease,
    top 260ms ease,
    opacity 260ms ease,
    transform 260ms ease;
}

.token-body.anchor {
  color: var(--blue);
  font-weight: 760;
}

.token-body.dust {
  color: rgba(247, 251, 255, 0.48);
  font-size: clamp(0.62rem, 1vw, 0.84rem);
}

.token-body.wobble {
  color: var(--warm);
}

.token-body.unstable::before {
  content: attr(data-band);
  position: absolute;
  left: -9px;
  right: -9px;
  top: 44%;
  min-height: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: var(--hot);
  border-left: 1px solid var(--hot);
  border-right: 1px solid var(--hot);
  font-size: 0.5rem;
  line-height: 1;
  text-transform: uppercase;
  animation: redactPulse 1.7s steps(2, end) infinite;
}

.redaction-band {
  z-index: 8;
  padding: 3px 8px;
  background: #000;
  color: var(--warm);
  border-left: 2px solid var(--hot);
  border-right: 2px solid var(--hot);
  font-size: 0.56rem;
  line-height: 1;
  text-transform: uppercase;
  animation: bandSweep 2.8s ease-in-out var(--band-delay) infinite;
}

.token-body.collapsing {
  left: 50% !important;
  top: 50% !important;
  opacity: 0;
  transform: translate(-50%, -50%) scaleX(0.08) !important;
  transition:
    left 720ms cubic-bezier(0.7, 0, 1, 1) var(--collapse-delay),
    top 720ms cubic-bezier(0.7, 0, 1, 1) var(--collapse-delay),
    opacity 520ms ease var(--collapse-delay),
    transform 720ms cubic-bezier(0.7, 0, 1, 1) var(--collapse-delay);
}

.capture-readout {
  position: absolute;
  z-index: 12;
  top: 10px;
  left: 10px;
  width: min(240px, calc(100% - 28px));
  display: grid;
  gap: 7px;
  color: var(--muted);
  font: 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: none;
}

.capture-readout div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(247, 251, 255, 0.1);
  padding-bottom: 6px;
}

.capture-readout strong {
  max-width: 145px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 680;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-actions {
  position: absolute;
  z-index: 24;
  left: 50%;
  bottom: 10px;
  width: min(760px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transform: translateX(-50%);
}

.collapse-button {
  min-width: 136px;
  border-color: var(--ink);
  background: rgba(156, 255, 128, 0.16);
  color: var(--ink);
  font-weight: 680;
}

.collapse-button:hover {
  background: rgba(255, 191, 0, 0.18);
  color: var(--warm);
}

.capture-sequence {
  min-width: 0;
  max-width: 560px;
  overflow: hidden;
  color: var(--muted);
  font: 0.72rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.radiation {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  background: #000;
}

.radiation-artifact,
.trace-event {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  overflow: hidden;
}

.radiation-artifact.assistant {
  border-color: rgba(156, 255, 128, 0.5);
}

.radiation-artifact.error,
.trace-event.error {
  border-color: var(--hot);
}

.radiation-artifact.system {
  border-color: rgba(255, 191, 0, 0.5);
}

.radiation-artifact header,
.trace-event header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--faint);
}

.glyph-artifact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  min-width: 0;
  border-bottom: 1px solid var(--faint);
}

.glyph-media {
  min-width: 0;
  display: grid;
  grid-template-columns: 240px minmax(280px, 1fr) 200px;
  gap: 1px;
  background: var(--faint);
}

.glyph-svg-wrap,
.glyph-canvas,
.glyph-source {
  min-width: 0;
  width: 100%;
  display: block;
  background: #000;
}

.glyph-svg-wrap,
.glyph-canvas {
  aspect-ratio: 1;
}

.glyph-svg-wrap {
  overflow: hidden;
}

.glyph-svg-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.glyph-canvas {
  height: auto;
}

.glyph-source {
  max-height: 240px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  color: var(--good);
  border: 0;
  font: 0.64rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.glyph-source::before {
  content: "$ cat artifact.svg";
  display: block;
  margin-bottom: 8px;
  color: var(--warm);
}

.glyph-readout {
  min-width: 0;
  padding: 10px;
  border-left: 1px solid var(--faint);
}

.glyph-readout h3 {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 680;
  letter-spacing: 0;
  text-transform: none;
}

.glyph-readout dl {
  gap: 7px;
}

.glyph-readout dl div {
  min-width: 0;
  gap: 10px;
  padding-bottom: 7px;
}

.glyph-readout dd {
  min-width: 0;
  max-width: 62%;
  overflow: hidden;
  color: var(--ink);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glyph-action {
  width: 100%;
  margin-top: 10px;
  border-color: rgba(156, 255, 128, 0.44);
  color: var(--good);
}

.mirror-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
}

.mirror-panel {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--faint);
}

.mirror-panel:last-child {
  border-right: 0;
}

.mirror-panel.full {
  border: 0;
}

.mirror-panel h3 {
  margin-bottom: 9px;
}

.text {
  max-width: 920px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.38;
}

.trace-event dl {
  padding: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trace-event dl div {
  min-width: 0;
}

.trace-event dd {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select:focus,
button:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: -2px;
}

@keyframes caretBlink {
  0%,
  46% {
    opacity: 1;
  }
  47%,
  100% {
    opacity: 0;
  }
}

@keyframes fragmentDrift {
  0%,
  100% {
    opacity: 0.18;
  }
  50% {
    opacity: 0.42;
  }
}

@keyframes redactPulse {
  0%,
  52% {
    opacity: 0.94;
  }
  53%,
  100% {
    opacity: 0.52;
  }
}

@keyframes bandSweep {
  0%,
  100% {
    opacity: 0.34;
    transform: translate(-56%, -50%) scaleX(0.72);
  }
  45%,
  60% {
    opacity: 0.9;
    transform: translate(-44%, -50%) scaleX(1.18);
  }
}

@media (max-width: 980px) {
  .surface {
    grid-template-columns: 1fr;
  }

  .stage {
    order: -1;
  }

  .rail {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    grid-template-rows: auto minmax(430px, 62vh) minmax(220px, 34vh);
  }
}

@media (max-width: 760px) {
  .mast,
  .stage-head,
  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .mast {
    gap: 14px;
  }

  .model-picker {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    max-width: none;
  }

  .stage-head {
    gap: 10px;
  }

  .substatement {
    max-width: none;
    text-align: left;
  }

  .composer {
    padding: 14px 12px 92px;
  }

  .horizon-field {
    height: clamp(360px, 58vh, 520px);
  }

  .void {
    width: clamp(132px, 36vw, 190px);
  }

  .orbit-line-outer {
    width: 96%;
    height: 56%;
  }

  .capture-readout {
    top: 10px;
    left: 10px;
    width: min(210px, calc(100% - 20px));
  }

  .capture-placeholder span {
    width: min(88vw, 360px);
  }

  .capture-placeholder {
    display: none;
  }

  .composer-actions {
    bottom: 12px;
    width: calc(100% - 24px);
    transform: translateX(-50%);
  }

  .collapse-button {
    width: 100%;
    min-height: 44px;
  }

  .capture-sequence {
    max-width: 100%;
  }

  .mirror-grid {
    grid-template-columns: 1fr;
  }

  .glyph-artifact,
  .glyph-media {
    grid-template-columns: 1fr;
  }

  .glyph-readout {
    border-left: 0;
    border-top: 1px solid var(--faint);
  }

  .mirror-panel {
    border-right: 0;
    border-bottom: 1px solid var(--faint);
  }

  .mirror-panel:last-child {
    border-bottom: 0;
  }

  .trace-event dl {
    grid-template-columns: 1fr;
  }
}
