:root {
  --ink-950: #020404;
  --ink-900: #0b1215;
  --mist-700: #4a5452;
  --aqua-500: #6be8da;
  --aqua-400: #9df7eb;
  --gold-500: #d4af37;
  --gold-400: #f0c85e;
  --gold-300: #ffe69c;
  --pearl-200: #d9e6ff;
  --pearl-100: #edf4ff;
  --paper: rgba(241, 247, 255, 0.78);
  --line: rgba(148, 172, 208, 0.45);
  --success: #1a7f37;
  --danger: #aa2e25;
  --shadow-soft: 0 12px 38px rgba(11, 17, 32, 0.12);
  --glow-gold: 0 0 16px rgba(212, 175, 55, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 90% -5%, rgba(107, 232, 218, 0.18), transparent 40%),
    radial-gradient(circle at 5% 25%, rgba(128, 163, 255, 0.14), transparent 46%),
    linear-gradient(160deg, #f6f9ff 0%, #eef6ff 55%, #e6f0ff 100%);
  color: var(--ink-950);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  background: var(--ink-900);
  color: #fff;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  z-index: 999;
}

.site-header {
  padding: 2rem 1.25rem 1rem;
  max-width: 1300px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(74, 84, 82, 0.25);
  background: rgba(11, 18, 21, 0.05);
  color: var(--mist-700);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.app-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-500);
  box-shadow: var(--glow-gold);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--mist-700);
}

h1,
h2,
h3,
h4 {
  font-family: "Fraunces", Georgia, serif;
  margin-top: 0;
}

h1 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.8rem, 3vw, 3.2rem);
}

.tagline {
  margin: 0;
  max-width: 70ch;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  background: linear-gradient(125deg, rgba(18, 33, 58, 0.92), rgba(38, 66, 103, 0.9));
  color: var(--pearl-100);
  border: 1px solid rgba(153, 191, 255, 0.28);
  border-radius: 10px;
  padding: 0.62rem 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(19, 33, 55, 0.2);
  border-color: rgba(240, 200, 94, 0.55);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.module-button:focus-visible {
  outline: 3px solid var(--aqua-500);
  outline-offset: 2px;
}

.layout {
  display: grid;
  gap: 1.25rem;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.graph-panel {
  /* background: var(--paper); */
  /* border: 1px solid var(--line); */
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  padding: 2rem;
  backdrop-filter: blur(6px);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.7rem;
}

.canvas-shell {
  position: relative;
  min-height: 420px;
  height: 70vh;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(157, 194, 255, 0.45);
  background:
    radial-gradient(circle at 70% 15%, rgba(107, 232, 218, 0.15), transparent 35%),
    radial-gradient(circle at 10% 70%, rgba(141, 174, 255, 0.2), transparent 40%),
    linear-gradient(165deg, #0d1730 0%, #0f1f3a 45%, #13294b 100%);
}

#mapBackdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  filter: saturate(0.9) contrast(1.05) brightness(0.85);
}

#mapBackdrop .leaflet-control-container {
  display: none;
}

#networkCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#networkCanvas.is-grabbing {
  cursor: grabbing;
}

.overlay-pill {
  position: absolute;
  top: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(243, 249, 255, 0.9);
  border: 1px solid rgba(240, 200, 94, 0.35);
  background: rgba(11, 21, 42, 0.55);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  backdrop-filter: blur(4px);
}

.export-comments-float {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 6;
  background: rgba(9, 18, 36, 0.82);
  border: 1px solid rgba(240, 200, 94, 0.35);
  color: var(--gold-300);
  font-size: 0.85rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.export-comments-float:hover {
  border-color: rgba(240, 200, 94, 0.75);
  box-shadow: var(--glow-gold);
  color: #fff;
}

.node-orb-popup {
  position: absolute;
  right: 1.1rem;
  bottom: 1rem;
  z-index: 5;
  width: min(560px, calc(100% - 2rem));
  height: min(560px, calc(100% - 4rem));
  border-radius: 50%;
  border: 1px solid rgba(183, 214, 255, 0.4);
  background:
    radial-gradient(circle at 30% 28%, rgba(107, 232, 218, 0.2), transparent 35%),
    radial-gradient(circle at 70% 70%, rgba(154, 190, 255, 0.2), transparent 45%),
    rgba(9, 18, 36, 0.8);
  color: #eef6ff;
  padding: 1.1rem;
  box-shadow: 0 16px 40px rgba(2, 9, 22, 0.45);
  backdrop-filter: blur(9px);
  display: flex;
  flex-direction: column;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.node-orb-popup.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px) scale(0.98);
}

.node-orb-popup::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(180, 217, 255, 0.22);
  pointer-events: none;
}

.focus-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  position: relative;
  z-index: 1;
}

.focus-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.focus-actions button {
  font-size: 0.8rem;
  padding: 0.45rem 0.62rem;
}

.node-orb-popup h3,
.node-orb-popup h4 {
  color: var(--gold-400);
}

.node-orb-popup h3 {
  text-shadow: 0 0 14px rgba(240, 200, 94, 0.35);
}

.orb-scroll {
  display: grid;
  gap: 0.65rem;
  overflow: auto;
  padding-right: 0.2rem;
  padding-bottom: 0.4rem;
  position: relative;
  z-index: 1;
}

.orb-section {
  background: rgba(14, 27, 50, 0.64);
  border: 1px solid rgba(166, 201, 255, 0.3);
  border-radius: 10px;
  padding: 0.65rem;
}

.fact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.fact-list li {
  color: #ffe9a8;
  border-left: 3px solid var(--gold-500);
  padding-left: 0.55rem;
  font-size: 0.92rem;
}

.module-buttons {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.module-button {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(248, 252, 255, 0.75);
  color: var(--ink-950);
  padding: 0.75rem;
  cursor: pointer;
}

.module-button[aria-current="true"] {
  border-color: rgba(53, 102, 168, 0.58);
  box-shadow: 0 0 0 2px rgba(107, 232, 218, 0.18);
  background: linear-gradient(130deg, rgba(107, 232, 218, 0.15), rgba(141, 174, 255, 0.14));
}

#selectedModulePrompts {
  margin: 0;
  padding-left: 1rem;
}

.comment-form {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
}

.form-row {
  display: grid;
  gap: 0.35rem;
}

input,
select,
textarea {
  border: 1px solid rgba(165, 197, 255, 0.35);
  border-radius: 8px;
  padding: 0.6rem;
  background: rgba(16, 31, 58, 0.88);
  color: #f2f8ff;
}

label {
  color: var(--pearl-200);
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.comment-item {
  border: 1px solid rgba(165, 197, 255, 0.3);
  border-left: 3px solid var(--aqua-500);
  border-radius: 10px;
  background: rgba(12, 23, 42, 0.8);
  padding: 0.65rem 0.75rem;
  color: #d8e8ff;
}

.comment-meta {
  color: var(--pearl-200);
  font-size: 0.9rem;
}

.chatbot-wrap {
  display: grid;
  gap: 0.65rem;
}

.chatbot-hint {
  margin: 0;
  color: #d3e7ff;
  font-size: 0.9rem;
}

.chatbot-status {
  font-size: 0.83rem;
  color: #c7e8ff;
  border: 1px solid rgba(160, 210, 255, 0.35);
  background: rgba(11, 21, 41, 0.62);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}

.chatbot-message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
  max-height: 260px;
  overflow: auto;
}

.chatbot-msg {
  border: 1px solid rgba(165, 197, 255, 0.32);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: rgba(10, 19, 37, 0.84);
}

.chatbot-msg p {
  margin: 0;
  color: #dfeeff;
  font-size: 0.92rem;
}

.chatbot-msg-user {
  border-left: 3px solid var(--aqua-500);
}

.chatbot-msg-assistant {
  border-left: 3px solid var(--gold-500);
}

.chatbot-msg-meta {
  margin-top: 0.35rem;
  color: #b9cdea;
  font-size: 0.78rem;
}

.chatbot-citations {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chatbot-citations a {
  color: #9df7eb;
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid rgba(157, 247, 235, 0.35);
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
}

.chatbot-citations a:hover {
  color: #fff;
  border-color: rgba(157, 247, 235, 0.7);
}

.chatbot-form {
  display: grid;
  gap: 0.65rem;
}

.empty-state {
  color: var(--pearl-200);
  font-style: italic;
}

.site-footer {
  max-width: 1300px;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  color: var(--ink-900);
}

@media (min-width: 920px) {
  .comment-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-row:last-of-type {
    grid-column: 1 / -1;
  }

  #submitCommentBtn {
    width: fit-content;
  }
}

@media (max-width: 760px) {
  .canvas-shell {
    min-height: 560px;
    height: 78vh;
  }

  .overlay-pill {
    width: calc(100% - 2rem);
    text-align: center;
  }

  .node-orb-popup {
    right: 0.45rem;
    left: 0.45rem;
    width: auto;
    height: min(560px, calc(100% - 3rem));
    border-radius: 24px;
    bottom: 0.6rem;
  }

  .node-orb-popup::before {
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}