* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--vx-font-system);
  background: var(--ct-bg);
  color: var(--ct-text);
  min-height: 100vh;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Nav rail */
.nav-rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 52px;
  z-index: 300;
  background: rgba(18, 26, 36, 0.95);
  border-right: 1px solid var(--ct-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  gap: 0.35rem;
}

.nav-rail button {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ct-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.nav-rail button:hover,
.nav-rail button.active {
  color: var(--ct-accent);
  border-color: rgba(61, 255, 168, 0.3);
  background: rgba(61, 255, 168, 0.08);
}

.nav-rail .god-btn {
  margin-top: auto;
  color: var(--vx-forming);
  border-color: rgba(201, 162, 39, 0.4);
}

.main-wrap {
  margin-left: 52px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.view {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* Hub */
.hub {
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.hub h1 {
  font-family: var(--vx-font-display);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.hub h1 em {
  color: var(--ct-accent);
  font-style: italic;
}

.hub .tagline {
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--ct-muted);
  margin-bottom: 2rem;
}

.hub .epigraph {
  font-family: var(--vx-font-display);
  font-style: italic;
  font-size: 1.25rem;
  max-width: 36ch;
  color: var(--ct-muted);
  margin-bottom: 3rem;
  line-height: 1.6;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  max-width: 640px;
  width: 100%;
}

.hub-card {
  padding: 1.25rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--vx-radius-card);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: left;
}

.hub-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  border-color: rgba(61, 255, 168, 0.25);
}

.hub-card h3 {
  font-family: var(--vx-font-display);
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

.hub-card p {
  font-size: 0.6rem;
  color: var(--ct-muted);
  letter-spacing: 0.08em;
}

.hub-private {
  margin-top: 2rem;
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--ct-muted);
  opacity: 0.5;
}

/* Desk */
.desk-header {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--ct-border);
}

.desk-title {
  font-family: var(--vx-font-display);
  font-size: 1.5rem;
}

.desk-title em {
  color: var(--ct-accent);
  font-style: italic;
}

.temperament {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--ct-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.temperament input {
  width: 72px;
  accent-color: var(--ct-accent);
}

.constellation {
  flex: 1;
  padding: 2rem 1.5rem 5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  align-content: flex-start;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.tile {
  width: 168px;
  min-height: 188px;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--vx-radius-tile);
  padding: 1rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.25s, box-shadow 0.25s;
  animation: breathe 3.5s ease-in-out infinite;
}

.tile:hover {
  transform: translateY(-4px);
}

.tile.shared {
  border-color: rgba(61, 255, 168, 0.45);
  box-shadow: 0 0 28px var(--vx-glow-shared);
}

.tile.parallel {
  border-color: rgba(107, 140, 255, 0.4);
}

.tile.memory {
  border-color: rgba(155, 126, 217, 0.4);
}

.tile .badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.5rem;
  letter-spacing: 0.08em;
}

.tile.shared .badge { color: var(--vx-shared); }
.tile.parallel .badge { color: var(--vx-parallel); }
.tile.memory .badge { color: var(--vx-memory); }

.tile h3 {
  font-family: var(--vx-font-display);
  font-size: 1.05rem;
  margin-top: 1.75rem;
  font-weight: 400;
  line-height: 1.2;
}

.tile .meta {
  font-size: 0.58rem;
  color: var(--ct-muted);
  margin-top: 0.35rem;
}

.tile .preview {
  height: 52px;
  margin-top: 0.65rem;
  border-radius: 8px;
}

.tile.add {
  border-style: dashed;
  opacity: 0.55;
  animation: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--ct-muted);
}

@keyframes breathe {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

.ask-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--ct-accent);
  color: var(--ct-bg);
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 0 36px var(--vx-glow-shared);
  animation: fab-pulse 4s ease-in-out infinite;
}

@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 0 24px var(--vx-glow-shared); }
  50% { box-shadow: 0 0 52px rgba(61, 255, 168, 0.5); }
}

/* World */
.world-view {
  background: radial-gradient(ellipse 90% 70% at 50% 30%, rgba(61, 255, 168, 0.06), var(--ct-bg));
}

.world-hud {
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.world-hud button {
  background: var(--vx-whisper-bg);
  border: 1px solid var(--ct-border);
  color: var(--ct-text);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.62rem;
  cursor: pointer;
  font-family: var(--vx-font-system);
}

.world-hud .together-ring {
  border-color: rgba(61, 255, 168, 0.5);
  box-shadow: 0 0 16px var(--vx-glow-shared);
}

.world-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 7rem;
  text-align: center;
}

.world-stage h1 {
  font-family: var(--vx-font-display);
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 400;
}

.world-stage h1 em {
  color: var(--ct-accent);
  font-style: italic;
}

.world-stage .verse {
  font-family: var(--vx-font-display);
  font-style: italic;
  color: var(--ct-muted);
  max-width: 40ch;
  margin-top: 1.25rem;
  line-height: 1.65;
  font-size: 1.1rem;
}

.world-stage .loop-hint {
  margin-top: 2rem;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--vx-forming);
}

.world-stage .lineage {
  margin-top: 1.5rem;
  font-size: 0.58rem;
  color: var(--ct-muted);
  letter-spacing: 0.1em;
}

.world-canvas {
  width: min(320px, 80vw);
  height: 120px;
  margin: 2rem 0;
  border-radius: 12px;
  border: 1px solid var(--ct-border);
  position: relative;
  overflow: hidden;
}

.world-canvas .orb {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ct-accent);
  animation: orbit 4s linear infinite;
}

@keyframes orbit {
  from { transform: rotate(0deg) translateX(80px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(80px) rotate(-360deg); }
}

.whisper-bar {
  position: fixed;
  bottom: 0;
  left: 52px;
  right: 0;
  padding: 0.85rem 1.25rem 1.25rem;
  background: var(--vx-whisper-bg);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--ct-border);
  display: flex;
  gap: 0.65rem;
  z-index: 40;
}

.whisper-bar input {
  flex: 1;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  color: var(--ct-text);
  font-family: var(--vx-font-display);
  font-style: italic;
  font-size: 0.95rem;
}

.btn {
  font-family: var(--vx-font-system);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--ct-border);
  background: transparent;
  color: var(--ct-text);
}

.btn-primary {
  background: var(--ct-accent);
  color: var(--ct-bg);
  border-color: var(--ct-accent);
}

.btn-danger {
  border-color: rgba(255, 107, 107, 0.4);
  color: #ff8a8a;
}

/* Overlays */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  left: 52px;
  z-index: 200;
  background: rgba(10, 14, 20, 0.94);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.overlay.open {
  display: flex;
}

.panel {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h2 {
  font-family: var(--vx-font-display);
  font-size: 1.85rem;
  text-align: center;
  margin-bottom: 0.35rem;
}

.panel .sub {
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  color: var(--ct-muted);
  margin-bottom: 1.25rem;
}

.ask-input,
.god-input {
  width: 100%;
  padding: 1rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--vx-radius-card);
  color: var(--ct-text);
  font-family: var(--vx-font-display);
  font-size: 1.05rem;
  font-style: italic;
  resize: vertical;
  min-height: 72px;
}

.forming-box {
  margin: 1rem 0;
  min-height: 100px;
  border: 1px dashed var(--vx-forming);
  border-radius: var(--vx-radius-card);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--vx-forming);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
}

.forming-box.visible {
  display: flex;
  animation: breathe 2s infinite;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.preview-card {
  display: none;
  position: fixed;
  bottom: 5rem;
  left: calc(52px + 50%);
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 80px));
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--vx-radius-card);
  padding: 1.15rem;
  z-index: 60;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.preview-card.open {
  display: block;
}

.preview-card p {
  font-size: 0.72rem;
  color: var(--ct-muted);
  line-height: 1.55;
  margin-bottom: 0.85rem;
}

.sheet {
  display: none;
  position: fixed;
  inset: 0;
  left: 52px;
  z-index: 180;
  background: rgba(10, 14, 20, 0.75);
  align-items: flex-end;
  justify-content: center;
}

.sheet.open {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-width: 440px;
  background: var(--ct-surface);
  border-radius: 22px 22px 0 0;
  padding: 1.35rem;
  border: 1px solid var(--ct-border);
  max-height: 70vh;
  overflow-y: auto;
}

.universe-opt {
  padding: 0.8rem;
  border-radius: 10px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.72rem;
  border: 1px solid transparent;
}

.universe-opt.live {
  border-color: rgba(61, 255, 168, 0.35);
  background: rgba(61, 255, 168, 0.06);
}

.universe-opt .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.45rem;
  background: var(--vx-parallel);
}

.universe-opt.live .dot {
  background: var(--ct-accent);
}

/* Veil */
.veil-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ct-border);
}

.veil-header h2 {
  font-family: var(--vx-font-display);
  font-size: 1.75rem;
}

.veil-search {
  margin-top: 1rem;
  width: 100%;
  max-width: 400px;
  padding: 0.65rem 1rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: 999px;
  color: var(--ct-text);
  font-size: 0.75rem;
}

.veil-body {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: center;
  align-content: flex-start;
}

.veil-node {
  width: 200px;
  padding: 1rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: var(--vx-radius-card);
  cursor: pointer;
  transition: border-color 0.2s;
}

.veil-node:hover {
  border-color: rgba(61, 255, 168, 0.4);
}

.veil-node h4 {
  font-family: var(--vx-font-display);
  font-size: 1rem;
}

.veil-node .depth {
  font-size: 0.58rem;
  color: var(--ct-accent);
  margin-top: 0.35rem;
}

.veil-node .from {
  font-size: 0.55rem;
  color: var(--ct-muted);
  margin-top: 0.25rem;
}

/* Book */
.book-body {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  max-width: 680px;
  margin: 0 auto;
  overflow-y: auto;
}

.book-body h1 {
  font-family: var(--vx-font-display);
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.book-body .chapter-title {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--vx-memory);
  margin: 2rem 0 1rem;
}

.book-body p {
  font-family: var(--vx-font-display);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ct-muted);
  margin-bottom: 1rem;
}

.book-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--ct-border);
}

.book-nav button {
  font-size: 0.6rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--ct-border);
  background: transparent;
  color: var(--ct-muted);
  cursor: pointer;
}

.book-nav button.active {
  color: var(--ct-accent);
  border-color: rgba(61, 255, 168, 0.35);
}

/* God panel */
.god-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(340px, 92vw);
  z-index: 250;
  background: rgba(18, 26, 36, 0.98);
  border-left: 1px solid rgba(201, 162, 39, 0.35);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  padding: 1.25rem;
  overflow-y: auto;
}

.god-panel.open {
  transform: translateX(0);
}

.god-panel h2 {
  font-family: var(--vx-font-display);
  font-size: 1.35rem;
  color: var(--vx-forming);
  margin-bottom: 0.25rem;
}

.god-panel .hint {
  font-size: 0.58rem;
  color: var(--ct-muted);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.god-field {
  margin-bottom: 1rem;
}

.god-field label {
  display: block;
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--ct-muted);
  margin-bottom: 0.35rem;
}

.god-field select {
  width: 100%;
  padding: 0.5rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  color: var(--ct-text);
  border-radius: 8px;
  font-size: 0.7rem;
}

.god-log {
  margin-top: 1rem;
  font-size: 0.58rem;
  color: var(--ct-muted);
  max-height: 120px;
  overflow-y: auto;
  border-top: 1px solid var(--ct-border);
  padding-top: 0.75rem;
}

.toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  margin-left: 26px;
  transform: translateX(-50%);
  padding: 0.6rem 1.2rem;
  background: var(--ct-surface);
  border: 1px solid var(--ct-border);
  border-radius: 999px;
  font-size: 0.62rem;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* Verse together mesh */
.sheet-panel--wide {
  max-width: 420px;
}

.sheet-kicker {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--ct-muted);
  margin-bottom: 0.5rem;
}

.sheet-lede {
  font-size: 0.68rem;
  color: var(--ct-muted);
  line-height: 1.55;
  margin-bottom: 1rem;
}

.together-seats {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.together-seat {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--ct-border);
  background: var(--ct-surface);
}

.together-seat.seat-agent {
  border-color: rgba(155, 126, 217, 0.45);
  box-shadow: 0 0 12px rgba(155, 126, 217, 0.12);
}

.together-seat .seat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ct-accent);
  flex-shrink: 0;
}

.seat-agent .seat-dot {
  background: var(--vx-forming);
  box-shadow: 0 0 8px var(--vx-forming);
}

.together-seat strong {
  display: block;
  font-size: 0.75rem;
}

.together-seat .seat-label,
.together-seat .seat-status {
  display: block;
  font-size: 0.58rem;
  color: var(--ct-muted);
  letter-spacing: 0.08em;
}

.mesh-log-title {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--ct-muted);
  margin-bottom: 0.5rem;
}

.mesh-log {
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.58rem;
  color: var(--ct-muted);
  border-top: 1px solid var(--ct-border);
  padding-top: 0.65rem;
  margin-bottom: 1rem;
}

.mesh-line {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.mesh-line--agent {
  color: rgba(155, 126, 217, 0.9);
}

.mesh-empty {
  font-size: 0.62rem;
  color: var(--ct-muted);
  font-style: italic;
}

.universe-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.world-hud .btn-publish {
  border-color: rgba(201, 162, 39, 0.45);
  color: var(--vx-forming);
}

.agent-suggestion {
  position: fixed;
  left: 52px;
  right: 0;
  bottom: 4.5rem;
  margin: 0 1rem;
  padding: 1rem 1.15rem;
  background: rgba(18, 26, 36, 0.96);
  border: 1px solid rgba(155, 126, 217, 0.4);
  border-radius: 12px;
  z-index: 45;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.agent-suggestion-kicker {
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--vx-forming);
  margin-bottom: 0.35rem;
}

.agent-suggestion h3 {
  font-family: var(--vx-font-display);
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
}

.agent-suggestion p {
  font-size: 0.68rem;
  color: var(--ct-muted);
  line-height: 1.5;
  margin-bottom: 0.85rem;
}

.agent-suggestion .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.play-back {
  position: fixed;
  top: 0.65rem;
  left: 56px;
  z-index: 60;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--ct-muted);
  text-decoration: none;
}

.play-back:hover {
  color: var(--ct-accent);
}

@media (max-width: 600px) {
  .nav-rail { width: 44px; }
  .main-wrap { margin-left: 44px; }
  .whisper-bar { left: 44px; }
  .overlay { left: 44px; }
  .sheet { left: 44px; }
  .agent-suggestion { left: 44px; }
  .play-back { left: 48px; }
}
