/* Calm editorial dark studio palette inspired by Distill.pub + industrial robotics:
   obsidian slate (#0f1218), whisper-thin hairlines, high-contrast neutral ink,
   and semantic color reserved strictly for data (coral cube, teal visual/rotated vector,
   amber shuffled control). */
:root {
  --bg: #0f1218;
  --surface: #161b24;
  --surface-hover: #1d2330;
  --viewport-bg: #141923;
  --text: #f0f2f6;
  --text-2: #9ba5b7;
  --text-3: #687386;
  --rule: rgba(255, 255, 255, 0.08);
  --rule-strong: rgba(255, 255, 255, 0.16);
  --primary-bg: #eef1f6;
  --primary-ink: #0f1218;
  --coral: #f54254;
  --cyan: #56d4c8;
  --amber: #f59e0b;
  --overlay: rgba(15, 18, 24, 0.84);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --text-col: 660px;
  --page-col: 960px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16.5px/1.68 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 3px; }

/* --- Editorial Header */

nav.site {
  max-width: var(--page-col);
  margin: 0 auto;
  padding: 18px 20px 0;
  font-size: 13px;
}

nav.site a { color: var(--text-3); text-decoration: none; transition: color 0.12s; }
nav.site a:hover { color: var(--text); }

.title {
  max-width: var(--page-col);
  margin: 0 auto;
  padding: 24px 20px 20px;
}

.title h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.description {
  margin: 0;
  max-width: 680px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-2);
}

.description strong { color: var(--text); font-weight: 500; }
.description code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--text);
  background: var(--surface);
  padding: 0 4px;
  border-radius: 4px;
}

/* --- Demo Stage */

.demo {
  max-width: var(--page-col);
  margin: 0 auto;
  padding: 0 20px;
}

.viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--viewport-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#view.can-grab { cursor: pointer; }
#view.grabbing { cursor: grabbing; }

.eye-pip {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 136px;
  background: var(--overlay);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(8px);
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
}

#eye {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
}

.eye-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 10.5px;
  font-family: var(--mono);
  white-space: nowrap;
  color: var(--text-2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#eye-phase { color: var(--cyan); }

.status, .note {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--overlay);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 13.5px;
  pointer-events: none;
  white-space: nowrap;
}

.status { top: 47%; }
.note { top: 14px; color: var(--cyan); font-size: 12.5px; }

/* --- Unified Command Composer */

.composer {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-bar input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 0 14px;
  font: 15.5px/1.3 var(--font);
  transition: border-color 0.14s, background 0.14s;
}

.prompt-bar input::placeholder { color: var(--text-3); }
.prompt-bar input:hover { border-color: rgba(255, 255, 255, 0.24); }
.prompt-bar input:focus {
  outline: none;
  border-color: var(--cyan);
  background: #181e29;
}

button {
  font: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}

button.primary {
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary-bg);
  color: var(--primary-ink);
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
}

button.primary:hover { opacity: 0.9; }

button.ghost {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  white-space: nowrap;
}

button.ghost:hover {
  color: var(--text);
  border-color: var(--rule-strong);
  background: var(--surface);
}

button:focus-visible, .chip:focus-visible, .seg:focus-visible, .inspector-toggle:focus-visible, .slow-toggle input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* --- Clickable Sample Prompts (single quiet row) */

.samples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.samples-label {
  font-size: 12px;
  color: var(--text-3);
  margin-right: 4px;
}

.chip {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  line-height: 1.4;
}

.chip:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--rule-strong);
}

.chip.active {
  color: var(--cyan);
  background: rgba(86, 212, 200, 0.08);
  border-color: rgba(86, 212, 200, 0.45);
}

/* --- Quiet Meta Strip (Rotation R switch + Live Status) */

.meta-bar {
  margin-top: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
}

.seg-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.seg-label {
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 2px;
}

.seg {
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 12px;
  font-family: var(--mono);
  line-height: 1.3;
}

.seg:hover { color: var(--text); }

.seg.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 500;
}

.seg.warn.active {
  background: rgba(245, 158, 11, 0.20);
  color: #fbbf24;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 12.5px;
}

.live-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.live-pill strong { color: var(--text); font-weight: 500; }
.live-pill .arrow { color: var(--cyan); }
.live-pill.unaligned .arrow { color: var(--amber); }

.live-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.slow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
}

.slow-toggle:hover { color: var(--text-2); }
.slow-toggle input { accent-color: var(--cyan); width: 14px; height: 14px; margin: 0; }

/* --- Progressive Disclosure Inspector */

.inspector {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.inspector-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 2px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.inspector-toggle::-webkit-details-marker { display: none; }
.inspector-toggle:hover { color: var(--text); }

.inspector-toggle > span:first-child::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--text-3);
  transition: transform 0.14s ease;
}

.inspector[open] .inspector-toggle > span:first-child::before {
  transform: rotate(90deg);
}

.inspector-toggle code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--text);
}

.badge {
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(86, 212, 200, 0.10);
  color: var(--cyan);
  border: 1px solid rgba(86, 212, 200, 0.28);
  white-space: nowrap;
}

.badge.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}

.rot-lab {
  display: grid;
  grid-template-columns: minmax(280px, 1.02fr) minmax(300px, 1.18fr);
  gap: 18px;
  padding: 6px 0 18px;
}

.rot-map-wrap, .rot-trace {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}

.trace-dim {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}

.map-key {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 9px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  font-family: var(--mono);
  white-space: nowrap;
}

.dot-k {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot-k.pre { border: 1.5px solid var(--amber); background: transparent; }
.dot-k.post { background: var(--cyan); }
.dot-k.nn { background: var(--coral); }

#latent-canvas {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--viewport-bg);
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 8px 11px;
}

.step-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 3px;
}

.step-title strong { color: var(--text); font-weight: 500; }

.step-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
  word-break: break-word;
}

.step-val .hi { color: var(--cyan); }
.step-val .warn { color: #fbbf24; }

.rot-footnote {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.48;
  color: var(--text-3);
}

.rot-footnote code {
  font-family: var(--mono);
  color: var(--text-2);
}

/* --- Editorial Prose */

.prose {
  max-width: var(--text-col);
  margin: 0 auto;
  padding: 44px 20px 84px;
  color: var(--text-2);
}

.prose h2 {
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 38px 0 10px;
  line-height: 1.3;
}

.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 16px; }
.prose ul { margin: 0 0 18px; padding-left: 20px; }
.prose li { margin: 0 0 9px; }
.prose strong { color: var(--text); font-weight: 500; }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.prose th, .prose td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}

.prose th {
  color: var(--text-3);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prose tr.highlight td { color: var(--text); background: rgba(86, 212, 200, 0.06); }
.prose .credits { margin-top: 40px; font-size: 13.5px; color: var(--text-3); }

@media (max-width: 780px) {
  .rot-lab { grid-template-columns: 1fr; }
  .live-pill { max-width: 260px; }
}

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .title { padding: 18px 16px 14px; }
  .demo { padding: 0 16px; }
  .viewport { aspect-ratio: 4 / 3.3; }
  .eye-pip { width: 108px; top: 8px; right: 8px; }
  .eye-caption { font-size: 9px; padding: 3px 6px; }
  .prompt-bar input { height: 42px; font-size: 15px; }
  button.primary, button.ghost { height: 42px; padding: 0 14px; font-size: 14px; }
  .meta-bar { gap: 10px; }
  .seg-group { width: 100%; justify-content: space-between; }
  .seg { padding: 4px 7px; font-size: 11.5px; }
  .meta-right { width: 100%; justify-content: space-between; }
  .live-pill { max-width: 62vw; }
  .prose { padding: 34px 16px 64px; }
}
