:root {
  --bg: #0e1412;
  --bg-elev: #17201c;
  --bg-panel: #141c19;
  --line: #2a3a34;
  --text: #e7f0eb;
  --muted: #9bb0a6;
  --accent: #3ecf8e;
  --accent-dim: #1f7a52;
  --warn: #e6b35a;
  --danger: #e07a6a;
  --a: #5ec8ff;
  --b: #3ecf8e;
  --c: #c9a227;
  --s: #b08cff;
  --ssh: #7dd3c0;
  --radius: 14px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a3329 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #142433 0%, transparent 50%),
    var(--bg);
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.mode-tabs {
  display: flex;
  gap: 0.4rem;
  background: rgba(0,0,0,0.25);
  padding: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 0.9rem var(--font);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.mode code { font-family: var(--mono); font-weight: 600; }
.mode:hover { color: var(--text); }
.mode.active {
  background: var(--accent);
  color: #062116;
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
  min-height: 0;
}

.scene-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

#canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(62,207,142,0.06), transparent 40%),
    #0a100e;
  /* Comfortable middle view: tall enough for labels, not tied to side panel */
  width: 100%;
  height: clamp(380px, calc(100vh - 10.5rem), 560px);
  min-height: 360px;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
}

#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Keep host titles inside the frame */
  overflow: hidden;
}

.host-label {
  position: absolute;
  transform: translate(-50%, -100%);
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  max-width: 11rem;
}
.host-label .name {
  font-weight: 650;
  font-size: 0.95rem;
}
.host-label .role {
  font-size: 0.72rem;
  color: var(--muted);
}
.host-label .badge {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--line);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.host-label .badge.on {
  opacity: 1;
  transform: translateY(0);
  border-color: var(--accent);
  color: var(--accent);
}
.host-label.dim { opacity: 0.35; }

.caption {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(8, 14, 12, 0.92);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  font-size: 0.9rem;
}
.caption .sep { color: var(--muted); }
.caption strong { color: var(--accent); font-weight: 600; }

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
  padding-right: 0.15rem;
  scrollbar-gutter: stable;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.card h2 {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}
.step {
  text-align: left;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: 500 0.9rem var(--font);
  cursor: pointer;
}
.step.active {
  color: var(--text);
  border-color: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.step-actions button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font: 500 0.85rem var(--font);
  cursor: pointer;
}
.step-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #062116;
}
.step-actions button:hover { filter: brightness(1.08); }

.step-copy {
  margin: 0.75rem 0 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.cmd {
  margin: 0;
  padding: 0.75rem 0.8rem;
  border-radius: 10px;
  background: #0a100e;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #d7efe4;
}
.cmd.anatomy {
  margin-top: 0.55rem;
  font-size: 0.72rem;
  color: #b7d4c8;
}
.card h2.sub {
  margin-top: 0.85rem;
}

.hops {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.hops li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.55rem;
  align-items: start;
}
.hop-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(62, 207, 142, 0.15);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
}
.hop-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.hop-body strong {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.hop-body em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.myths ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}
.myths li { margin-bottom: 0.4rem; }
.myths li strong { color: var(--text); font-weight: 600; }

.footnote {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.footnote a { color: var(--a); }
.footnote code { font-family: var(--mono); font-size: 0.75rem; }

@media (max-width: 920px) {
  .stage { grid-template-columns: 1fr; }
  #canvas-wrap {
    height: clamp(300px, 48vh, 440px);
    min-height: 280px;
  }
  .panel {
    max-height: none;
    overflow: visible;
  }
}

@media (min-width: 1400px) {
  #app { max-width: 1400px; margin: 0 auto; }
  #canvas-wrap {
    height: clamp(420px, calc(100vh - 10rem), 600px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode, .host-label .badge { transition: none; }
}

.host-label.hidden-host {
  opacity: 0.28;
  filter: grayscale(0.35);
}
.host-label .badge.on {
  outline: 1px solid color-mix(in srgb, var(--s) 55%, transparent);
}
