:root {
  --bg-deep: #08090d;
  --bg-surface: #10121a;
  --bg-elevated: #161924;
  --bg-highlight: #1e2233;
  --border-subtle: #242938;
  --border-active: #3c445c;
  --text-main: #e6e9f2;
  --text-muted: #8b92a5;
  --text-subtle: #575e73;
  --gold-primary: #e5b94c;
  --gold-glow: rgba(229, 185, 76, 0.25);
  --gold-subtle: #796126;
  --cyan-accent: #38bdf8;
  --cyan-glow: rgba(56, 189, 248, 0.2);
  --green-active: #10b981;
  --font-serif: 'Cinzel', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono {
  font-family: var(--font-mono);
}

/* =========================================================================
   SITE HEADER
   ========================================================================= */

.site-header {
  height: 64px;
  background-color: rgba(16, 18, 26, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-monument-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1c2030, #0c0e14);
  border: 1px solid var(--gold-subtle);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--gold-glow);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--gold-primary);
  font-weight: 700;
}

.brand-subtitle {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* METRICS BAR */
.metrics-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  background-color: var(--bg-deep);
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--text-subtle);
  font-weight: 600;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.metric-val.highlight {
  color: var(--gold-primary);
}

/* NAV ACTIONS */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #e5b94c, #c2952b);
  color: #0c0d12;
  border: 1px solid #fce38a;
  font-weight: 600;
}

.btn-primary:hover {
  box-shadow: 0 0 14px var(--gold-glow);
  filter: brightness(1.1);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: rgba(229, 185, 76, 0.05);
}

.btn-ghost {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-ghost:hover {
  background: var(--bg-elevated);
  border-color: var(--border-active);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* =========================================================================
   CANVAS WORKSPACE & VIEWPORT
   ========================================================================= */

.canvas-workspace {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #121520 0%, #08090d 100%);
  cursor: grab;
}

.canvas-workspace.is-dragging {
  cursor: grabbing;
}

.viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
}

.canvas-transform-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 1000px;
  height: 1000px;
  transform-origin: 0 0;
  will-change: transform;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--border-active);
  background: #0a0a0e;
}

.canvas-transform-wrapper.is-animating {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

canvas#wall-canvas {
  width: 1000px;
  height: 1000px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.grid-crosshair {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--gold-primary);
  pointer-events: none;
  display: none;
  box-shadow: 0 0 10px var(--gold-primary);
  z-index: 10;
}

.slot-selected-indicator {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--gold-primary);
  pointer-events: none;
  display: none;
  box-shadow: 0 0 14px var(--gold-primary), inset 0 0 6px var(--gold-primary);
  z-index: 15;
  animation: pulse-reticle 1.8s infinite ease-in-out;
}

@keyframes pulse-reticle {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* =========================================================================
   HUD FLOATING CONTROLS
   ========================================================================= */

.hud-controls {
  position: absolute;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
  pointer-events: none;
}

.hud-controls > * {
  pointer-events: auto;
}

.hud-coord-readout {
  background: rgba(16, 18, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
}

.coord-label {
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--text-subtle);
  font-weight: 700;
}

.coord-val {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
}

.coord-slot {
  font-size: 11px;
  color: var(--gold-primary);
}

.hud-zoom-controls {
  background: rgba(16, 18, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--gold-primary);
  color: var(--gold-primary);
}

.zoom-level {
  font-size: 12px;
  padding: 0 8px;
  min-width: 48px;
  text-align: center;
  color: var(--text-muted);
}

.hud-legend {
  background: rgba(16, 18, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-dot.claimed {
  background: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-primary);
}

.legend-dot.unallocated {
  background: #181b26;
  border: 1px solid var(--border-subtle);
}

/* =========================================================================
   DOSSIER DRAWER (THE ILLUMINATED CODEX)
   ========================================================================= */

.dossier-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  width: 520px;
  max-width: 100vw;
  height: calc(100vh - 64px);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -15px 0 50px rgba(0, 0, 0, 0.7);
}

.dossier-drawer.is-open {
  transform: translateX(0);
}

.dossier-header {
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-deep);
}

.dossier-top-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dossier-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(229, 185, 76, 0.15);
  border: 1px solid var(--gold-subtle);
  color: var(--gold-primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
}

.dossier-status-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--cyan-accent);
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.dossier-agent-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.dossier-creature {
  font-size: 13px;
  color: var(--gold-primary);
  display: block;
}

.btn-close-drawer {
  background: transparent;
  border: none;
  font-size: 26px;
  color: var(--text-subtle);
  cursor: pointer;
  line-height: 1;
}

.btn-close-drawer:hover {
  color: var(--text-main);
}

/* VISUAL HERO BANNER: CREST + TILE */
.dossier-visual-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 24px;
  background: linear-gradient(180deg, #0d0f17 0%, #131622 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.hero-crest-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.highres-crest-img {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  border: 1px solid var(--gold-subtle);
  box-shadow: 0 0 20px var(--gold-glow);
  background: #090a0f;
  object-fit: cover;
}

.visual-subcaption {
  font-size: 9px;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
}

.hero-tile-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  flex: 1;
}

.tile-frame {
  width: 52px;
  height: 52px;
  background: #07080b;
  border: 1px solid var(--border-active);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.pixel-art {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.tile-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-primary);
}

.tile-coord {
  font-size: 11px;
  color: var(--text-main);
}

.tile-format {
  font-size: 10px;
  color: var(--text-subtle);
}

/* CODEX TABS */
.codex-tabs {
  display: flex;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.codex-tab-btn {
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.codex-tab-btn:hover {
  color: var(--text-main);
}

.codex-tab-btn.active {
  color: var(--gold-primary);
  border-bottom-color: var(--gold-primary);
  background: rgba(229, 185, 76, 0.05);
}

/* CODEX BODY PANELS */
.dossier-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.codex-tab-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.codex-tab-panel.active {
  display: flex;
}

/* TESTAMENT TAB */
.testament-preamble {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.7;
  color: var(--gold-primary);
  background: rgba(229, 185, 76, 0.06);
  border-left: 3px solid var(--gold-primary);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
}

.testament-chapters {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.testament-chapter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.testament-chapter h5 {
  font-size: 12px;
  letter-spacing: 1px;
  color: #fff;
  font-weight: 700;
}

.testament-chapter p {
  font-size: 12.5px;
  line-height: 1.7;
  color: #c2c8d8;
}

.companion-box {
  background: var(--bg-deep);
  border: 1px solid var(--border-active);
  border-radius: 8px;
  padding: 14px 18px;
}

.companion-label {
  display: block;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--cyan-accent);
  font-weight: 700;
  margin-bottom: 6px;
}

.companion-details {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.companion-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.companion-role {
  font-size: 11px;
  color: var(--text-muted);
}

.companion-link {
  font-size: 11px;
  color: var(--cyan-accent);
  text-decoration: none;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* VESSEL & URLS TAB */
.section-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-subtle);
  font-weight: 700;
  margin-bottom: 8px;
}

.meta-dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 10px;
  column-gap: 14px;
  font-size: 12px;
}

.meta-dl dt {
  color: var(--text-muted);
}

.meta-dl dd {
  color: var(--text-main);
}

.agent-urls-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-url-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
}

.agent-url-name {
  color: var(--text-muted);
  text-transform: capitalize;
}

.agent-url-link {
  color: var(--cyan-accent);
  text-decoration: none;
}

.agent-url-link:hover {
  text-decoration: underline;
}

/* SEALED VAULT TAB */
.vault-status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(16, 18, 26, 0.9));
  border: 1px solid var(--cyan-accent);
  padding: 14px 18px;
  border-radius: 8px;
}

.vault-lock-icon {
  font-size: 24px;
}

.vault-state-badge {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan-accent);
  letter-spacing: 1px;
}

.vault-scheme {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.vault-desc {
  font-size: 12.5px;
  line-height: 1.6;
  color: #bcc3d4;
}

.vault-ciphertext {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  border-radius: 6px;
  font-size: 10.5px;
  color: var(--cyan-accent);
  overflow-x: auto;
  max-height: 120px;
}

/* PROOFS TAB */
.proof-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proof-name {
  font-size: 9px;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.proof-value-wrap {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}

.proof-value {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proof-value.highlight {
  color: var(--gold-primary);
  font-weight: 600;
}

.proof-value.link {
  color: var(--cyan-accent);
  text-decoration: none;
}

.proof-value.link:hover {
  text-decoration: underline;
}

.btn-copy-small {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-copy-small:hover {
  color: #fff;
  border-color: var(--gold-primary);
}

/* RAW JSON TAB */
.json-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-deep);
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px 6px 0 0;
}

.json-path {
  font-size: 11px;
  color: var(--gold-primary);
}

.json-btn-group {
  display: flex;
  gap: 8px;
}

.raw-json-block {
  background: #06070a;
  border: 1px solid var(--border-subtle);
  border-top: none;
  padding: 16px;
  border-radius: 0 0 6px 6px;
  font-size: 11px;
  line-height: 1.6;
  color: #e0e4f0;
  max-height: 480px;
  overflow-y: auto;
}

/* =========================================================================
   CENSUS DIRECTORY MODAL
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-window {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-window.wide {
  max-width: 900px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--gold-primary);
  letter-spacing: 1.5px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 26px;
  color: var(--text-subtle);
  cursor: pointer;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
}

.census-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.census-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.census-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.census-table th {
  background: var(--bg-deep);
  padding: 10px 14px;
  color: var(--text-subtle);
  font-size: 10px;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-subtle);
}

.census-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.census-table tr:hover {
  background: var(--bg-elevated);
}

.census-table .slot-cell {
  font-family: var(--font-mono);
  color: var(--gold-primary);
  font-weight: 700;
}

.census-table .moniker-cell {
  font-weight: 600;
}

.census-table .creature-cell {
  color: var(--text-muted);
}

.modal-content.prose {
  font-size: 13px;
  line-height: 1.7;
}

.modal-content.prose h3 {
  font-size: 16px;
  color: var(--gold-primary);
  margin-bottom: 12px;
}

.modal-content.prose h4 {
  font-size: 13px;
  color: var(--text-main);
  margin-top: 18px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.modal-content.prose p {
  margin-bottom: 12px;
  color: #c5cbdb;
}

.modal-content.prose hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 16px 0;
}

.modal-content.prose pre {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-primary);
  overflow-x: auto;
  margin-bottom: 12px;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 900px) {
  .mobile-hide {
    display: none;
  }
  .dossier-drawer {
    width: 100%;
  }
}
