:root {
  --bg: #080c13;
  --bg-card: #0f1623;
  --bg-elev: #151f32;
  --bg-input: #0b111c;
  --border: rgba(148, 163, 184, 0.16);
  --border-bright: rgba(245, 158, 11, 0.45);
  --text: #e6edf7;
  --text-muted: #94a3b8;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.14);
  --violet: #c084fc;
  --rose: #fb7185;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: radial-gradient(circle at 18% 0%, #131d31 0%, var(--bg) 52%);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

code, pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.site-header {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 1rem;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
}

.brand-block {
  max-width: 820px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.35rem;
}

h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.85rem, 3.2vw, 2.65rem);
  letter-spacing: -0.02em;
  background: linear-gradient(95deg, #fff7ed 0%, #fcd34d 48%, #5eead4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
}

.subtitle strong {
  color: var(--text);
}

.quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.quick-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s;
}

.quick-nav a:hover {
  border-color: var(--amber);
  background: var(--bg-elev);
}

.kpi-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.kpi-pill {
  background: rgba(15, 22, 35, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.kpi-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--amber);
  white-space: nowrap;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.noscript-card {
  max-width: 1280px;
  margin: 1rem auto;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--amber);
  border-radius: 12px;
}

.atelier-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.95fr);
  gap: 1.25rem;
  align-items: start;
}

.stage-card,
.inspector-card,
.full-card,
.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

.stage-card {
  padding: 1rem;
}

.stage-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.cage-selector-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 290px;
}

.cage-select,
.puzzle-select,
.atlas-controls select,
.jump-group input {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.86rem;
}

.cage-select {
  width: 100%;
  max-width: 370px;
  font-weight: 600;
}

.icon-btn,
.pill-btn,
.seg-btn,
.toggle-btn,
.action-btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.42rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.14s ease;
}

.icon-btn:hover,
.pill-btn:hover,
.seg-btn:hover,
.toggle-btn:hover,
.action-btn:hover:not(:disabled) {
  border-color: rgba(245, 158, 11, 0.55);
  background: #1c2942;
}

.action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.cat-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill-btn.active,
.seg-btn.active,
.toggle-btn.active {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: #fde68a;
  font-weight: 600;
}

.amber-btn {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
  font-weight: 600;
}

.teal-btn {
  background: var(--teal-soft);
  border-color: rgba(45, 212, 191, 0.55);
  color: #99f6e4;
  font-weight: 600;
}

.canvas-wrap {
  position: relative;
  background: radial-gradient(circle at 50% 44%, #131e33 0%, #070b12 78%);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}

#cage-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 760 / 530;
  cursor: grab;
  touch-action: none;
}

#cage-canvas:active {
  cursor: grabbing;
}

.canvas-hud-top {
  position: absolute;
  top: 0.7rem;
  left: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  pointer-events: none;
}

.hud-badge {
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 0.25rem 0.58rem;
  border-radius: 6px;
  background: rgba(8, 12, 19, 0.82);
  border: 1px solid var(--border);
  color: var(--text);
}

.hud-amber {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fcd34d;
}

.hud-teal {
  border-color: rgba(45, 212, 191, 0.5);
  color: #5eead4;
}

.sw-banner {
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  max-width: 340px;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  background: rgba(15, 22, 35, 0.92);
  border: 1px solid var(--amber);
  color: #fef3c7;
}

.hidden {
  display: none !important;
}

.canvas-hint {
  position: absolute;
  bottom: 0.55rem;
  left: 0.8rem;
  right: 0.8rem;
  font-size: 0.76rem;
  color: rgba(203, 213, 225, 0.72);
  pointer-events: none;
}

.gold-dot {
  color: var(--amber);
}

.stage-controls {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
}

.control-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.cluster-label {
  font-family: var(--mono);
  font-size: 0.73rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.morph-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.28rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.morph-label input[type="range"] {
  width: 84px;
  accent-color: var(--amber);
}

.puzzle-bar {
  background: rgba(11, 17, 28, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.26);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.puzzle-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.puzzle-kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--amber);
}

.puzzle-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* RIGHT INSPECTOR */
.inspector-card {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.cage-title-block h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.chirality-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.chirality-tag.achiral {
  background: var(--teal-soft);
  color: #5eead4;
  border: 1px solid rgba(45, 212, 191, 0.4);
}

.chirality-tag.chiral {
  background: rgba(192, 132, 252, 0.16);
  color: #e9d5ff;
  border: 1px solid rgba(192, 132, 252, 0.45);
}

.info-story {
  margin: 0.45rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.telemetry-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.t-cell {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.65rem;
}

.t-cell dt {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.t-cell dd {
  margin: 0.12rem 0 0;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.spiral-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
}

.spiral-label {
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.15rem;
}

.spiral-box code {
  color: #fcd34d;
  word-break: break-word;
}

.spectrum-block {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.spectrum-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.spectrum-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.spec-sub {
  margin: 0.15rem 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.audio-btns {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

#orbital-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
}

/* ATLAS & CENSUS SECTIONS */
.full-card {
  padding: 1.35rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.45rem;
}

.section-desc {
  margin: 0;
  max-width: 720px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.atlas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

.atlas-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.jump-group {
  display: flex;
  gap: 0.35rem;
}

.jump-group input {
  width: 132px;
}

.atlas-body {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 0.95fr);
  gap: 1.1rem;
  align-items: start;
}

.atlas-canvas-wrap {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

#atlas-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.atlas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(8, 12, 19, 0.95);
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
  z-index: 10;
  max-width: 260px;
}

.atlas-sidebar h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.landmark-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
}

.landmark-list li {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
}

.landmark-list li span {
  display: block;
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 0.12rem;
}

.link-isomer {
  background: none;
  border: none;
  padding: 0;
  color: #fcd34d;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.83rem;
  text-align: left;
}

.link-isomer:hover {
  text-decoration: underline;
}

.island-summary-box {
  margin-top: 0.75rem;
  background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.79rem;
}

.island-summary-box p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

#census-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.9rem;
}

.table-scroll {
  overflow-x: auto;
}

.census-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.census-table th,
.census-table td {
  padding: 0.48rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-family: var(--mono);
}

.census-table th:first-child,
.census-table td:first-child,
.census-table th:last-child,
.census-table td:last-child {
  text-align: left;
  font-family: var(--sans);
}

.census-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.census-table tr.zero-row td {
  color: #fca5a5;
  background: rgba(244, 63, 94, 0.07);
}

/* FIELD NOTES */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.15rem;
}

.note-card {
  padding: 1.25rem 1.35rem;
}

.note-num {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.note-card h3 {
  margin: 0.3rem 0 0.65rem;
  font-size: 1.1rem;
  color: #fef3c7;
}

.note-card p {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: #cbd5e1;
}

.note-card p:last-child {
  margin-bottom: 0;
}

.site-footer {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: center;
}

.site-footer a {
  color: var(--amber);
}

@media (max-width: 920px) {
  .panel-grid,
  .atlas-body {
    grid-template-columns: 1fr;
  }
}
