:root {
  --phi: 1.6180339887;
  --phi-inv: 0.6180339887;
  --accent: #eeeae1;
  --accent-rgb: 238, 234, 225;
  --accent-dim: rgba(238, 234, 225, 0.56);
  --accent-soft: rgba(238, 234, 225, 0.14);
  --border-hair: rgba(255, 255, 255, 0.12);
  --panel-bg: rgba(5, 6, 8, 0.70);

  /* Matte Scientific Semantic Palette (Obsidian Void Exact Preservation) */
  --matte-le: #c48f5c;
  --matte-be: #6e9aba;
  --matte-sage: #74a085;
  --matte-brass: #ae9865;
  --matte-violet: #9381ab;
  --matte-rust: #b86d60;
  --matte-ivory: #eeeae1;
}

.m-le     { color: var(--matte-le); }
.m-be     { color: var(--matte-be); }
.m-sage   { color: var(--matte-sage); }
.m-brass  { color: var(--matte-brass); }
.m-violet { color: var(--matte-violet); }
.m-rust   { color: var(--matte-rust); }
.m-ivory  { color: var(--matte-ivory); }

body.theme-obsidian {
  --accent: #eeeae1;
  --accent-rgb: 238, 234, 225;
  --accent-dim: rgba(235, 236, 240, 0.56);
  --accent-soft: rgba(238, 234, 225, 0.14);
  --border-hair: rgba(255, 255, 255, 0.13);
}
body.theme-phosphor {
  --accent: #4ade80;
  --accent-rgb: 74, 222, 128;
  --accent-dim: rgba(134, 239, 172, 0.58);
  --accent-soft: rgba(74, 222, 128, 0.16);
  --border-hair: rgba(74, 222, 128, 0.22);
}
body.theme-titanium {
  --accent: #7dd3fc;
  --accent-rgb: 125, 211, 252;
  --accent-dim: rgba(186, 230, 253, 0.58);
  --accent-soft: rgba(125, 211, 252, 0.16);
  --border-hair: rgba(125, 211, 252, 0.22);
}

*, *::before, *::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  color: #e8ecf2;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  line-height: 1.35;
}

button {
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0;
}

input {
  font-family: inherit;
}

.hidden { display: none !important; }

/* Chamfered 45-degree Aerospace HUD Panels */
.fui-panel {
  position: relative;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  clip-path: polygon(
    10px 0%, 100% 0%, 100% calc(100% - 10px),
    calc(100% - 10px) 100%, 0% 100%, 0% 10px
  );
  box-shadow: inset 0 0 0 1px var(--border-hair), 0 0 28px rgba(0, 0, 0, 0.75);
}
.fui-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), 0.38) 0px, rgba(var(--accent-rgb), 0.38) 8px, transparent 8.5px),
    linear-gradient(315deg, rgba(var(--accent-rgb), 0.38) 0px, rgba(var(--accent-rgb), 0.38) 8px, transparent 8.5px);
}

.fui-btn {
  border: 1px solid var(--border-hair);
  background: rgba(var(--accent-rgb), 0.03);
  color: var(--accent-dim);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  clip-path: polygon(5px 0%, 100% 0%, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0% 100%, 0% 5px);
  padding: 4px 8px;
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.fui-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.65);
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}
.fui-btn.is-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.75);
}
.fui-btn-sm {
  padding: 4px 6px;
  font-size: 7.2px;
  letter-spacing: 0.14em;
}
.fui-btn-full {
  width: 100%;
  display: block;
  text-align: center;
}

.accent-text { color: var(--accent); }
.glow-soft {
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7), 0 0 22px rgba(var(--accent-rgb), 0.28);
}

/* Precision Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(var(--accent-rgb), 0.18);
  height: 1px;
  outline: none;
  width: 100%;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.45); }
input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 0;
  background: var(--accent);
  cursor: pointer;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* Canvas Layers */
.layer-gl, .layer-hud {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.layer-gl { z-index: 0; cursor: grab; }
.layer-gl:active { cursor: grabbing; }
.layer-hud { z-index: 10; pointer-events: none; }

/* UI Shell */
.ui-layer {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.zen-fade {
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
body.zen-mode .zen-fade {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-6px);
}
body.zen-mode footer.zen-fade { transform: translateY(16px); }

/* Top Bar */
.top-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: 12px;
}
.hdr-left { display: flex; align-items: center; gap: 12px; }
.hdr-stack { display: flex; flex-direction: column; }
.hdr-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hdr-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}
.hdr-sub {
  font-size: 8px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.40);
  text-transform: uppercase;
  margin-top: 2px;
}
.badge {
  font-size: 8px;
  padding: 2px 6px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.badge-brass  { border-color: rgba(174, 152, 101, 0.42); color: var(--matte-brass); }
.badge-rust   { border-color: rgba(184, 109, 96, 0.38);  color: var(--matte-rust); }
.badge-sage   { border-color: rgba(116, 160, 133, 0.48); color: var(--matte-sage); }
.badge-le     { border-color: rgba(196, 143, 92, 0.60);  color: var(--matte-le); }
.badge-violet { border-color: rgba(147, 129, 171, 0.60); color: var(--matte-violet); }

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #ffffff;
  animation: ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
  flex-shrink: 0;
}
@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}

.hdr-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.osc-box {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.02);
  color: rgba(255, 255, 255, 0.40);
}
.palette-group {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.40);
}
.palette-btn {
  padding: 2px 6px;
  font-size: 8px;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.14em;
}
.palette-btn:hover { color: #ffffff; }
.palette-btn.is-on { color: #ffffff; background: rgba(255, 255, 255, 0.20); }

.sound-btn { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 9999px; display: inline-block; flex-shrink: 0; }
.dot-off { background: #ef4444; }
.dot-on  { background: #34d399; animation: pulseDot 1.4s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Middle Floating Rails */
.rails-wrap {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px 8px;
  overflow: hidden;
}
.rail-left, .rail-right {
  display: none;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}
.rail-left  { width: 276px; }
.rail-right { width: 238px; margin-left: auto; }

.panel-pad { padding: 12px; }
.stack-xs > * + * { margin-top: 4px; }
.stack-sm > * + * { margin-top: 6px; }
.stack-md > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 10px; }

.sec-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  letter-spacing: 0.22em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  padding-bottom: 4px;
  font-weight: 500;
}
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.lbl-dim { color: rgba(255, 255, 255, 0.42); }
.lbl-soft { color: rgba(255, 255, 255, 0.56); }
.t-68 { font-size: 6.8px; letter-spacing: 0.12em; }
.t-70 { font-size: 7px;   letter-spacing: 0.14em; }
.t-75 { font-size: 7.5px; letter-spacing: 0.14em; }
.t-80 { font-size: 8px;   letter-spacing: 0.16em; }
.t-95 { font-size: 9.5px; letter-spacing: 0.08em; }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-top { padding-top: 5px; border-top: 1px solid rgba(255, 255, 255, 0.10); }

.matrix-canvas { width: 100%; height: 44px; display: block; }
.radar-wrap { display: flex; align-items: center; gap: 12px; }
.radar-meta { flex: 1; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.swatch { width: 6px; height: 6px; border-radius: 9999px; display: inline-block; }
.sw-le     { background: var(--matte-le); }
.sw-be     { background: var(--matte-be); }
.sw-sage   { background: var(--matte-sage); }
.sw-brass  { background: var(--matte-brass); }
.sw-violet { background: var(--matte-violet); }
.sw-ivory  { background: var(--matte-ivory); }

/* Optical Interference Fringe Veil (Classified Internal Module Shield) */
.fringe-box {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(0, 0, 0, 0.48);
  overflow: hidden;
  padding: 10px 8px;
  min-height: 64px;
  clip-path: polygon(5px 0%, 100% 0%, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0% 100%, 0% 5px);
}
.fringe-bg-lines {
  font-size: 7px;
  letter-spacing: 0.12em;
  color: rgba(238, 234, 225, 0.14);
  line-height: 1.5;
  text-align: center;
}
.fringe-veil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background-color: rgba(5, 6, 8, 0.88);
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(174, 152, 101, 0.16) 0px,
      rgba(174, 152, 101, 0.16) 1px,
      rgba(5, 6, 8, 0.92) 1px,
      rgba(5, 6, 8, 0.92) 5px,
      rgba(147, 129, 171, 0.14) 5px,
      rgba(147, 129, 171, 0.14) 6px,
      rgba(5, 6, 8, 0.92) 6px,
      rgba(5, 6, 8, 0.92) 11px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(238, 234, 225, 0.05) 0px,
      rgba(238, 234, 225, 0.05) 1px,
      transparent 1px,
      transparent 8px
    );
  background-size: 22px 100%, 16px 16px;
  animation: fringeShift 6.4s linear infinite;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.fringe-label {
  font-size: 7px;
  letter-spacing: 0.2em;
  color: var(--matte-brass);
  background: rgba(5, 6, 8, 0.90);
  border: 1px solid rgba(174, 152, 101, 0.40);
  padding: 2px 7px;
  text-transform: uppercase;
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.85);
}
.fringe-sub {
  font-size: 6.4px;
  letter-spacing: 0.16em;
  color: rgba(238, 234, 225, 0.52);
  text-transform: uppercase;
}
@keyframes fringeShift {
  0%   { background-position: 0px 0px, 0px 0px; }
  100% { background-position: 22px 0px, 16px 0px; }
}

/* Bottom Control Deck */
.bottom-deck {
  pointer-events: auto;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.slider-track {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}
.phi-tick {
  position: absolute;
  top: -6px;
  width: 1px;
  height: 14px;
  pointer-events: none;
}
.phi-tick-1 { left: 38.2%; background: rgba(255, 255, 255, 0.30); }
.phi-tick-2 { left: 61.8%; background: rgba(255, 255, 255, 0.52); }
.btn-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* Boot Banner */
#bootBanner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  pointer-events: none;
  text-align: center;
  transition: opacity 0.7s ease;
}
.boot-title {
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  font-weight: 500;
}
.boot-bar-wrap {
  width: 224px;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 8px auto;
  overflow: hidden;
}
.boot-bar {
  height: 100%;
  background: #ffffff;
  width: 0%;
  transition: width 0.1s linear;
}
.boot-sub {
  font-size: 8px;
  letter-spacing: 0.30em;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
}

/* Holographic Cards & Modals */
.modal-card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s ease;
}
.genesis-card {
  bottom: 80px;
  width: 90%;
  max-width: 440px;
  padding: 16px;
}
.forensic-card {
  top: 64px;
  width: 92%;
  max-width: 580px;
  padding: 16px;
}
.forensic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font-size: 8px;
}
.forensic-cell {
  padding: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.forensic-span2 { grid-column: span 2; }
.fc-be     { border-color: rgba(110, 154, 186, 0.32); }
.fc-brass  { border-color: rgba(174, 152, 101, 0.32); }
.fc-rust   { border-color: rgba(184, 109, 96, 0.35); }
.fc-violet { border-color: rgba(147, 129, 171, 0.32); }
.fc-sage   { border-color: rgba(116, 160, 133, 0.35); }

.modal-close {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.16em;
  padding: 2px 4px;
}
.modal-close:hover { color: #ffffff; }
.quote-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding-top: 6px;
  font-size: 8px;
  font-style: italic;
  text-align: center;
  opacity: 0.85;
}

/* Command Palette */
#cmdPalette {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cmd-panel { width: 92%; max-width: 480px; padding: 16px; }
.cmd-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 8px 12px;
  font-size: 10px;
  color: #ffffff;
  outline: none;
}
.cmd-input:focus { border-color: rgba(255, 255, 255, 0.50); }
.cmd-list { max-height: 224px; overflow-y: auto; }
.cmd-item {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  transition: all 0.14s ease;
}
.cmd-item:hover {
  border-color: rgba(255, 255, 255, 0.40);
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

#exitZenHint {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  background: rgba(0, 0, 0, 0.72);
  font-size: 8px;
  letter-spacing: 0.26em;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#exitZenHint:hover { color: #ffffff; }

/* 404 Page */
body.err-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.err-card { max-width: 400px; width: 100%; padding: 20px; }
.err-head { display: flex; justify-content: space-between; font-size: 8px; letter-spacing: 0.2em; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 8px; }
.err-title { font-size: 14px; letter-spacing: 0.28em; margin: 16px 0 8px; font-weight: 600; }
.err-copy { font-size: 9px; color: rgba(255,255,255,0.58); margin: 0 0 16px; }
.err-link { display: inline-block; text-decoration: none; }

::-webkit-scrollbar { width: 2px; height: 2px; }
::-webkit-scrollbar-thumb { background: rgba(var(--accent-rgb), 0.28); }

@media (min-width: 768px) {
  .palette-group { display: flex; }
}
@media (min-width: 1024px) {
  .rail-left, .rail-right { display: flex; }
}
@media (min-width: 1280px) {
  .osc-box { display: flex; }
}
@media (max-width: 640px) {
  .forensic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
