/* ========================================================
   CYBER NOTES — Deep Ocean Theme
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=IBM+Plex+Mono:wght@400;500&family=Lora:ital,wght@0,400;0,500;1,400&display=swap');

/* ========== Tokens ========== */

:root {
  /* Ocean depth palette */
  --abyss:      #060d1a;
  --deep:       #0c1829;
  --mid:        #112135;
  --surface:    #16283f;
  --foam:       #1e3a55;

  /* Bioluminescent accents */
  --glow:       #00c9b1;
  --glow-dim:   rgba(0, 201, 177, 0.18);
  --glow-line:  rgba(0, 201, 177, 0.35);
  --coral:      #ff7e5f;
  --coral-dim:  rgba(255, 126, 95, 0.15);
  --seafoam:    #7ed8d0;
  --pearl:      #cfe8ea;

  /* Text */
  --text-primary:   #d8eef2;
  --text-secondary: #7bafc0;
  --text-muted:     #4a7a8a;

  /* Borders & shadows */
  --border:     rgba(0, 201, 177, 0.12);
  --border-mid: rgba(0, 201, 177, 0.22);
  --shadow-sm:  0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.6);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
}

/* ========== Reset & Base ========== */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--abyss);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.7;
}

/* ========== Ocean Background ========== */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 80%, rgba(0, 120, 110, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 20%, rgba(0, 60, 100, 0.25) 0%, transparent 55%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(255, 126, 95, 0.04) 0%, transparent 70%),
    linear-gradient(170deg, #060d1a 0%, #0c1829 40%, #0a1e30 100%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ========== Sidebar ========== */

#sidebar {
  width: 280px;
  min-width: 280px;
  background: rgba(12, 24, 41, 0.92);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  position: relative;
}

/* Subtle shimmer line at top */
#sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--glow), transparent);
  opacity: 0.6;
}

/* Sidebar scroll area */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--foam) transparent;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--foam);
  border-radius: 4px;
}

/* Brand */
#sidebar h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--glow);
  text-shadow: 0 0 18px rgba(0, 201, 177, 0.45);
  padding: 18px 14px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* Search */
#search {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 10px;
}

#search::placeholder { color: var(--text-muted); }

#search:focus {
  outline: none;
  border-color: var(--glow);
  box-shadow: 0 0 0 3px var(--glow-dim), 0 0 16px rgba(0, 201, 177, 0.1);
}

/* Search results */
#search-results {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--foam) transparent;
}

.search-result {
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
}

.search-result:hover {
  background: var(--glow-dim);
  color: var(--glow);
  border-left-color: var(--glow);
}

/* ========== Tree ========== */

#tree { font-size: 0.83rem; }

.folder { margin: 2px 0; }

.folder-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s, background 0.15s;
  user-select: none;
}

.folder-name::before {
  content: '▸';
  font-size: 0.65rem;
  transition: transform 0.2s;
  color: var(--glow);
  flex-shrink: 0;
}

.folder-name.open::before { transform: rotate(90deg); }

.folder-name:hover {
  color: var(--seafoam);
  background: rgba(0, 201, 177, 0.06);
}

.folder-children {
  margin-left: 12px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
  margin-top: 2px;
  margin-bottom: 4px;
}

.note-link {
  display: block;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.3;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border-left: 2px solid transparent;
}

.note-link:hover {
  background: var(--glow-dim);
  color: var(--pearl);
  border-left-color: var(--glow-line);
}

.note-link.active {
  background: rgba(0, 201, 177, 0.12);
  color: var(--glow);
  border-left-color: var(--glow);
}

/* ========== Main ========== */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

/* Breadcrumb */
#breadcrumb {
  padding: 13px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 24, 41, 0.6);
  backdrop-filter: blur(10px);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

#breadcrumb span { color: var(--glow); }

/* Content area — scrollable shell only, no layout centering here */
#content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--foam) transparent;
}

/* .prose div injected by JS wraps all rendered markdown */
.prose {
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  padding: 44px 32px 80px;
  min-width: 0;  /* allow children to shrink/scroll correctly */
}

/* pre gets full prose column width and scrolls horizontally */
.prose pre {
  width: 100%;
  box-sizing: border-box;
}

#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb {
  background: var(--foam);
  border-radius: 4px;
}

/* ========================================================
   MARKDOWN ELEMENTS
   ======================================================== */

/* --- Headings --- */

#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  color: var(--pearl);
  line-height: 1.25;
  scroll-margin-top: 80px;
}

#content h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  padding-bottom: 14px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-mid);
  position: relative;
}

#content h1::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0;
  width: 60px; height: 2px;
  background: var(--glow);
  box-shadow: 0 0 10px var(--glow);
  border-radius: 2px;
}

#content h2 {
  font-size: 1.35rem;
  color: var(--seafoam);
  margin-top: 2.2em;
  margin-bottom: 0.7em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

#content h3 {
  font-size: 1.1rem;
  color: var(--glow);
  margin-top: 1.6em;
  margin-bottom: 0.5em;
  letter-spacing: 0.02em;
}

#content h4 {
  font-size: 0.95rem;
  color: var(--seafoam);
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}

#content h5, #content h6 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 1em;
  margin-bottom: 0.3em;
}

/* --- Paragraphs --- */

#content p {
  color: var(--text-primary);
  line-height: 1.8;
  margin: 0.75em 0;
  font-size: 0.95rem;
}

/* --- Links --- */

#content a {
  color: var(--glow);
  text-decoration: none;
  border-bottom: 1px solid var(--glow-line);
  transition: color 0.15s, border-color 0.15s, text-shadow 0.15s;
}

#content a:hover {
  color: var(--seafoam);
  border-bottom-color: var(--seafoam);
  text-shadow: 0 0 12px rgba(126, 216, 208, 0.4);
}

/* Wiki links */
.wikilink {
  color: var(--coral) !important;
  border-bottom-color: rgba(255, 126, 95, 0.35) !important;
}

.wikilink:hover {
  color: #ffb09a !important;
  border-bottom-color: rgba(255, 176, 154, 0.6) !important;
  text-shadow: 0 0 12px rgba(255, 126, 95, 0.4) !important;
}

/* --- Code — inline --- */

#content code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82em;
  background: rgba(0, 201, 177, 0.1);
  color: var(--glow);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--glow-line);
}

/* --- Code — block --- */

#content pre {
  background: rgba(6, 13, 26, 0.85);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--glow);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin: 1.4em 0;
  overflow-x: auto;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(0, 201, 177, 0.06);
  position: relative;
}

#content pre::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--glow), transparent 70%);
  opacity: 0.4;
  border-radius: var(--r-md) var(--r-md) 0 0;
}

#content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.65;
}

/* --- Blockquote --- */

#content blockquote {
  margin: 1.2em 0;
  padding: 14px 18px 14px 20px;
  border-left: 3px solid var(--coral);
  background: var(--coral-dim);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text-secondary);
  font-style: italic;
  position: relative;
}

#content blockquote p { color: var(--text-secondary); margin: 0; }

/* --- Horizontal rule --- */

#content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glow-line), transparent);
  margin: 2em 0;
}

/* --- Lists --- */

#content ul, #content ol {
  padding-left: 1.6em;
  margin: 0.7em 0;
}

#content li {
  margin: 0.35em 0;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.7;
}

#content ul li::marker { color: var(--glow); }
#content ol li::marker {
  color: var(--seafoam);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
}

/* Nested lists */
#content li > ul, #content li > ol { margin: 0.3em 0; }

/* --- Tables --- */

#content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.4em 0;
  font-size: 0.88rem;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-mid);
}

#content thead {
  background: rgba(0, 201, 177, 0.12);
}

#content th {
  padding: 11px 14px;
  text-align: left;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--glow);
  border-bottom: 1px solid var(--border-mid);
}

#content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
  line-height: 1.5;
}

#content tbody tr {
  background: rgba(255, 255, 255, 0.01);
  transition: background 0.15s;
}

#content tbody tr:hover {
  background: rgba(0, 201, 177, 0.05);
}

#content tbody tr:last-child td { border-bottom: none; }

/* --- Images --- */

#content img {
  max-width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--border-mid);
  box-shadow: var(--shadow-lg);
  margin: 0.8em 0;
  display: block;
}

/* --- Strong / Em --- */

#content strong { color: var(--pearl); font-weight: 600; }
#content em { color: var(--seafoam); font-style: italic; }

/* ========== Loading state ========== */

#content.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}

/* ========== Scrollbar (content) ========== */

#content * { scroll-margin-top: 80px; }

/* ========== Empty / placeholder state ========== */

#content > p:first-child:only-child {
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================================
   SPLASH SCREEN
   ======================================================== */

#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* fade-out class added by JS */
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

#splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Deep ocean gradient background */
.splash-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 20% 90%, rgba(0, 120, 110, 0.28) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 80% 10%, rgba(0, 50, 100, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(0, 201, 177, 0.06) 0%, transparent 60%),
    linear-gradient(170deg, #04090f 0%, #060d1a 45%, #081525 100%);
  z-index: 0;
}

/* ── Animated waves ── */
.splash-waves {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 120px;
  z-index: 1;
}

.splash-waves svg {
  width: 100%;
  height: 100%;
}

.wave {
  fill-opacity: 0.18;
  animation: wave-drift 6s ease-in-out infinite;
}

.wave-1 {
  fill: #00c9b1;
  animation-duration: 7s;
  animation-delay: 0s;
}

.wave-2 {
  fill: #00a896;
  animation-duration: 9s;
  animation-delay: -3s;
}

.wave-3 {
  fill: #007d70;
  animation-duration: 11s;
  animation-delay: -5s;
  fill-opacity: 0.12;
}

@keyframes wave-drift {
  0%   { transform: translateX(0);     }
  50%  { transform: translateX(-40px); }
  100% { transform: translateX(0);     }
}

/* ── Center content ── */
.splash-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: splash-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes splash-rise {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ── Wheel container ── */
.wheel-wrap {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ship-wheel {
  width: 150px;
  height: 150px;
  animation: wheel-spin 12s linear infinite;
  filter: drop-shadow(0 0 18px rgba(0, 201, 177, 0.55));
}

@keyframes wheel-spin {
  from { transform: rotate(0deg);   }
  to   { transform: rotate(360deg); }
}

/* Pulsing glow ring behind the wheel */
.wheel-glow-ring {
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 201, 177, 0.2);
  animation: ring-pulse 2.8s ease-in-out infinite;
}

.wheel-glow-ring::before {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 201, 177, 0.1);
  animation: ring-pulse 2.8s ease-in-out infinite;
  animation-delay: 0.5s;
}

@keyframes ring-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.6; }
  50%       { transform: scale(1.08); opacity: 0.15; }
}

/* ── Title ── */
.splash-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: 0.28em;
  color: var(--glow);
  text-shadow: 0 0 30px rgba(0, 201, 177, 0.5), 0 0 60px rgba(0, 201, 177, 0.2);
  text-align: center;
  margin: 0;
}

.splash-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  animation: blink-dot 1.4s steps(3, end) infinite;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.3; }
}

/* ── Progress bar ── */
.splash-bar-wrap {
  width: 160px;
  height: 2px;
  background: rgba(0, 201, 177, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.splash-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--glow), var(--seafoam));
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(0, 201, 177, 0.7);
  animation: bar-fill 1.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.3s;
}

@keyframes bar-fill {
  from { width: 0%;    }
  80%  { width: 85%;   }
  to   { width: 100%;  }
}

/* ========================================================
   MOBILE SUPPORT
   ======================================================== */

#menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#menu-toggle:hover {
  background: var(--glow-dim);
  border-color: var(--glow-line);
}

#menu-toggle span,
#menu-toggle span::before,
#menu-toggle span::after {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--glow);
  border-radius: 2px;
  position: relative;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

#menu-toggle span::before,
#menu-toggle span::after {
  content: '';
  position: absolute;
  left: 0;
}

#menu-toggle span::before { top: -5px; }
#menu-toggle span::after  { top:  5px; }

#menu-toggle.open span          { background: transparent; }
#menu-toggle.open span::before  { transform: translateY(5px) rotate(45deg); }
#menu-toggle.open span::after   { transform: translateY(-5px) rotate(-45deg); }

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#sidebar-overlay.visible { opacity: 1; }

/* Bigger touch targets for all interactive sidebar items */
.note-link,
.folder-name,
.search-result {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  html, body { overflow: auto; }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
  }

  #sidebar-overlay { display: block; pointer-events: none; }
  #sidebar-overlay.visible { pointer-events: auto; }

  #main {
    width: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  /* Breadcrumb: button + text side by side, sticky at top */
  #breadcrumb {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 52px;
  }

  #breadcrumb-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #menu-toggle { display: flex; flex-shrink: 0; }

  /* Content scrolls with the page on mobile */
  #content {
    flex: 1;
    overflow-y: visible;
    height: auto;
  }

  .prose { padding: 24px 16px 80px; max-width: 100%; }

  /* Larger touch targets in sidebar */
  .note-link   { padding: 10px 10px; font-size: 0.88rem; }
  .folder-name { padding: 10px 8px;  font-size: 0.75rem; }
  .search-result { padding: 10px 10px; font-size: 0.85rem; }

  #content h1 { font-size: 1.55rem; }
  #content h2 { font-size: 1.15rem; }
  #content h3 { font-size: 1rem;    }

  #content pre { padding: 14px 14px 18px; }
  #content pre code { font-size: 0.78rem; }

  /* Horizontally scrollable tables */
  #content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: max-content;
    max-width: 100%;
  }

  /* Prevent text-size adjustment on orientation change */
  body { -webkit-text-size-adjust: 100%; }
}

}

@media (max-width: 480px) {
  #sidebar  { width: 88vw; }
  .prose    { padding: 18px 14px 80px; }
  #content h1 { font-size: 1.3rem; }
}

/* ========================================================
   GRAPH VIEW
   ======================================================== */

/* --- Graph toggle button in breadcrumb --- */

#breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
}

#breadcrumb-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#graph-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: rgba(0, 201, 177, 0.05);
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

#graph-toggle:hover {
  background: var(--glow-dim);
  border-color: var(--glow);
  color: var(--glow);
  box-shadow: 0 0 12px rgba(0, 201, 177, 0.15);
}

/* --- Graph overlay --- */

#graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#graph-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#graph-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 15% 85%, rgba(0, 120, 110, 0.16) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 85% 15%, rgba(0, 50, 100, 0.22) 0%, transparent 55%),
    linear-gradient(170deg, #04090f 0%, #060d1a 50%, #081525 100%);
  z-index: 0;
}

/* Subtle grid */
#graph-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 201, 177, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 201, 177, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* --- Graph header --- */

#graph-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 13, 26, 0.85);
  backdrop-filter: blur(16px);
  flex-shrink: 0;
}

.graph-header-left {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--glow);
}

.graph-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--glow);
  text-shadow: 0 0 16px rgba(0, 201, 177, 0.4);
}

.graph-hint {
  flex: 1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

#graph-close {
  padding: 6px 14px;
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

#graph-close:hover {
  background: rgba(255, 80, 80, 0.1);
  border-color: rgba(255, 80, 80, 0.4);
  color: #ff7b7b;
}

/* --- Graph SVG canvas --- */

#graph-svg {
  flex: 1;
  width: 100%;
  position: relative;
  z-index: 1;
  cursor: grab;
}

#graph-svg:active { cursor: grabbing; }

/* --- Tooltip --- */

#graph-tooltip {
  position: absolute;
  z-index: 10;
  padding: 7px 12px;
  background: rgba(12, 24, 41, 0.95);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--glow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 201, 177, 0.12);
  white-space: nowrap;
}

#graph-tooltip.visible { opacity: 1; }

/* --- Graph node labels (set via D3, but base style) --- */

.graph-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  fill: var(--text-secondary);
  pointer-events: none;
  dominant-baseline: auto;
}

/* --- Graph loading state --- */

#graph-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}

.graph-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--glow);
  border-radius: 50%;
  animation: graph-spin 0.9s linear infinite;
}

@keyframes graph-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .graph-hint { display: none; }
  #graph-header { padding: 10px 14px; }
  #graph-toggle span { display: none; } /* hide "Graph" text, keep icon */
}
