/* ============================================================================
 * Stella Nova Education — Embodied Identity Explorer v2.0
 * Official Stella Nova Navy / Blue Palette (Exclusively Dark Cartographic Theme)
 * ============================================================================ */
:root {
  --sn-bg: #020c17;
  --sn-bg2: #031426;
  --sn-panel: #061b2d;
  --sn-panel2: #08243a;
  --sn-panel3: #0b304d;
  --sn-line: #155e8e;
  --sn-line-soft: rgba(21, 94, 142, 0.42);
  --sn-cyan: #43b7ff;
  --sn-blue: #147bd1;
  --sn-blue2: #0b5fae;
  --sn-text: #e7f5ff;
  --sn-muted: #8eb3ca;
  --sn-dim: #5d829a;
  --sn-green: #45c66b;
  --sn-yellow: #f1b941;
  --sn-orange: #f08b29;
  --sn-red: #ef5360;
  --sn-violet: #9778f0;
  --sn-radius: 8px;
  color-scheme: dark;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 0%, #08243f 0%, var(--sn-bg) 48%, #01070e 100%);
  color: var(--sn-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body {
  background-image:
    radial-gradient(circle at 50% 0%, rgba(18, 92, 148, 0.24) 0%, transparent 55%),
    linear-gradient(rgba(67, 183, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67, 183, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 34px 34px, 34px 34px;
}
a { color: var(--sn-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Official Stella Nova Education Brand Header */
.sn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #04182c 0%, #02101f 100%);
  border-bottom: 1px solid var(--sn-line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.sn-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--sn-text);
  flex-shrink: 0;
}
.sn-brand:hover { text-decoration: none; }
.sn-brand-star {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--sn-cyan);
  background: radial-gradient(circle, rgba(67,183,255,0.22) 0%, rgba(11,95,174,0.12) 70%);
  border: 1px solid rgba(67, 183, 255, 0.55);
  box-shadow: 0 0 14px rgba(67, 183, 255, 0.25);
}
.sn-brand-text strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: #f0f9ff;
}
.sn-brand-text small {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--sn-cyan);
  opacity: 0.9;
}
.sn-title-block {
  flex: 1;
  text-align: center;
  min-width: 0;
}
.sn-title-block h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: #ffffff;
}
.sn-title-block p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--sn-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sn-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Buttons & Panels */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--sn-line);
  background: var(--sn-panel2);
  color: var(--sn-text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.btn:hover { background: var(--sn-panel3); border-color: var(--sn-cyan); }
.btn-primary {
  background: linear-gradient(180deg, #2798e6 0%, #0f68b8 100%);
  border-color: #53c0ff;
  color: #ffffff;
}
.btn-primary:hover { background: linear-gradient(180deg, #3aa8f2 0%, #1577cc 100%); }
.btn-ghost { background: transparent; border-color: var(--sn-line-soft); color: var(--sn-muted); }
.btn-ghost:hover { color: var(--sn-text); border-color: var(--sn-cyan); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.panel {
  background: linear-gradient(180deg, rgba(8, 33, 55, 0.94) 0%, rgba(5, 22, 38, 0.96) 100%);
  border: 1px solid var(--sn-line-soft);
  border-radius: var(--sn-radius);
  box-shadow: 0 10px 28px rgba(0, 7, 15, 0.45);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 13px;
  background: rgba(11, 44, 72, 0.65);
  border-bottom: 1px solid var(--sn-line-soft);
  border-radius: var(--sn-radius) var(--sn-radius) 0 0;
}
.panel-head h2, .panel-head h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9e6fa;
}

/* Primary Navigation Bar (Visible in Explorer Mode) */
.sn-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 16px;
  background: #041526;
  border-bottom: 1px solid var(--sn-line-soft);
  overflow-x: auto;
  white-space: nowrap;
}
.sn-nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--sn-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.sn-nav-tab:hover { color: var(--sn-text); }
.sn-nav-tab.active {
  color: var(--sn-cyan);
  border-bottom-color: var(--sn-cyan);
  background: rgba(67, 183, 255, 0.08);
}

/* ============================================================================
 * Landing Page (Public Introduction, How It Works, Sensitivity & Disclaimers)
 * ============================================================================ */
.landing-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.landing-hero {
  padding: 36px 34px;
  border-radius: 12px;
  background: radial-gradient(circle at 82% 18%, rgba(67,183,255,0.16) 0%, rgba(6,27,45,0.95) 58%);
  border: 1px solid var(--sn-line);
  box-shadow: 0 18px 48px rgba(0, 8, 18, 0.6);
}
.landing-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sn-cyan);
  margin-bottom: 10px;
  font-weight: 600;
}
.landing-hero h2 {
  margin: 0 0 12px;
  font-size: clamp(24px, 3.2vw, 36px);
  line-height: 1.18;
  color: #ffffff;
  max-width: 820px;
}
.landing-hero p {
  margin: 0 0 22px;
  font-size: 15px;
  color: #c5dff0;
  max-width: 780px;
}
.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.landing-cta-row .btn { padding: 11px 20px; font-size: 13.5px; }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 16px;
  border-radius: 8px;
  background: rgba(7, 29, 48, 0.88);
  border: 1px solid var(--sn-line-soft);
}
.stat-card .stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--sn-cyan);
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-lbl {
  font-size: 12px;
  color: var(--sn-muted);
  margin-top: 2px;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
}
.how-card {
  padding: 18px;
}
.how-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #ffffff;
}
.how-card p {
  margin: 0;
  font-size: 13px;
  color: var(--sn-muted);
}

.disclaimer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
}
.disclaimer-box {
  padding: 18px 20px;
  border-radius: 8px;
  background: rgba(12, 32, 52, 0.85);
  border: 1px solid rgba(241, 185, 65, 0.42);
}
.disclaimer-box.scientific {
  border-color: rgba(67, 183, 255, 0.42);
}
.disclaimer-box h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  letter-spacing: 0.04em;
  color: var(--sn-yellow);
}
.disclaimer-box.scientific h3 { color: var(--sn-cyan); }
.disclaimer-box p {
  margin: 0 0 8px;
  font-size: 12.8px;
  color: #cde3f2;
}
.disclaimer-box p:last-child { margin-bottom: 0; }

/* ============================================================================
 * Explorer Workspace (3-Column Grid + High-Fidelity MapLibre Stage)
 * ============================================================================ */
.workspace-shell { padding: 12px 16px 24px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.explorer-grid {
  display: grid;
  grid-template-columns: 270px minmax(420px, 1fr) 360px;
  gap: 12px;
  align-items: start;
}
.control-rail { max-height: calc(100vh - 140px); overflow-y: auto; }
.rail-body { padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.rail-group { border-bottom: 1px solid var(--sn-line-soft); padding-bottom: 12px; }
.rail-group:last-child { border-bottom: none; padding-bottom: 0; }
.rail-group h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sn-muted);
}

.field-input, .field-select, .field-textarea {
  width: 100%;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--sn-line-soft);
  background: #031323;
  color: var(--sn-text);
  font-size: 12.5px;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--sn-cyan);
  box-shadow: 0 0 0 2px rgba(67, 183, 255, 0.2);
}

.eco-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
}
.eco-row:hover { background: rgba(67, 183, 255, 0.08); }
.eco-row.active { background: rgba(67, 183, 255, 0.18); border: 1px solid rgba(67,183,255,0.45); }
.eco-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  cursor: pointer;
}
.toggle-line input { accent-color: var(--sn-cyan); }

/* Map Stage */
.map-stage-card { display: flex; flex-direction: column; overflow: hidden; }
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(11, 44, 72, 0.72);
  border-bottom: 1px solid var(--sn-line-soft);
  font-size: 12px;
}
.map-canvas-wrap {
  position: relative;
  height: 540px;
  background: #031526;
}
#eie-map { width: 100%; height: 100%; }
.map-fallback-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.map-overlay-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  background: rgba(2, 16, 31, 0.86);
  border: 1px solid var(--sn-line);
  color: var(--sn-text);
  pointer-events: none;
}
.unbounded-tray {
  padding: 9px 12px;
  background: #04182b;
  border-top: 1px solid var(--sn-line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.unbounded-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-btn {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--sn-line);
  background: var(--sn-panel2);
  color: var(--sn-text);
  font-size: 11.5px;
}
.chip-btn:hover { border-color: var(--sn-cyan); background: var(--sn-panel3); }

/* Right Inspector */
.detail-panel { max-height: calc(100vh - 140px); overflow-y: auto; }
.detail-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 12.8px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv-box {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(3, 19, 35, 0.72);
  border: 1px solid var(--sn-line-soft);
}
.kv-box .k { font-size: 11px; color: var(--sn-muted); }
.kv-box .v { font-size: 12.5px; font-weight: 600; margin-top: 2px; word-break: break-word; }

.guard-banner {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12.2px;
  border: 1px solid var(--sn-line);
  background: rgba(20, 123, 209, 0.14);
}
.guard-banner.warn { border-color: rgba(241, 185, 65, 0.55); background: rgba(241, 185, 65, 0.12); color: #fde6a4; }
.guard-banner.ok { border-color: rgba(69, 198, 107, 0.55); background: rgba(69, 198, 107, 0.12); color: #baf2ca; }
.guard-banner.danger { border-color: rgba(239, 83, 96, 0.58); background: rgba(239, 83, 96, 0.14); color: #ffc0c6; }

/* ============================================================================
 * Slide-Over Complex Visual Provenance Tree Drawer
 * ============================================================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: none;
  justify-content: flex-end;
}
.drawer-backdrop.open { display: flex; }
.provenance-drawer {
  width: min(1080px, 96vw);
  height: 100vh;
  background: #031222;
  border-left: 1px solid var(--sn-line);
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 48px rgba(0, 5, 12, 0.8);
}
.drawer-header {
  padding: 14px 20px;
  background: #061d33;
  border-bottom: 1px solid var(--sn-line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.drawer-legend {
  padding: 8px 20px;
  background: #041628;
  border-bottom: 1px solid var(--sn-line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--sn-muted);
}
.drawer-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(20, 123, 209, 0.12) 0%, #020e1b 75%),
    linear-gradient(rgba(67, 183, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67, 183, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
  cursor: grab;
}
.drawer-canvas-wrap:active { cursor: grabbing; }
.drawer-canvas-wrap svg { width: 100%; height: 100%; display: block; }
.drawer-node-inspector {
  padding: 14px 20px;
  background: #061b2f;
  border-top: 1px solid var(--sn-line);
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: 16px;
  font-size: 12.8px;
}

/* Data Tables & Secondary Views */
.section-card { padding: 18px; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table.sn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.sn-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--sn-line);
  color: var(--sn-cyan);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
table.sn-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(21, 94, 142, 0.25);
  vertical-align: top;
}
table.sn-table tr:hover td { background: rgba(67, 183, 255, 0.06); }

/* Auth / Account Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 8, 16, 0.78);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: min(480px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
}
.form-stack { display: flex; flex-direction: column; gap: 11px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sn-muted); }

/* Footer */
.sn-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sn-line-soft);
  background: #020d19;
  font-size: 12px;
  color: var(--sn-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 1080px) {
  .explorer-grid { grid-template-columns: 1fr; }
  .control-rail, .detail-panel { max-height: none; }
  .map-canvas-wrap { height: 420px; }
  .drawer-node-inspector { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .sn-title-block { display: none; }
  .landing-hero { padding: 24px 18px; }
}
