:root {
  --panel: rgba(9, 21, 34, 0.84);
  --panel-border: rgba(133, 170, 197, 0.18);
  --text: #eef6ff;
  --text-dim: #96acc0;
  --accent: #ffd46b;
  --accent-cool: #63d8ea;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-sans: "Avenir Next", "Segoe UI Variable", "Segoe UI", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(99, 216, 234, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 212, 107, 0.14), transparent 22%),
    radial-gradient(circle at 20% 80%, rgba(74, 144, 226, 0.1), transparent 28%),
    linear-gradient(155deg, #040a11 0%, #09131d 38%, #0d1824 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: "SFMono-Regular", "Cascadia Code", monospace;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  padding: 14px;
  overflow: hidden;
}

.explorer-shell {
  --note-panel-width: 420px;
  --detective-panel-width: 420px;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px minmax(320px, var(--note-panel-width));
  gap: 0;
  overflow: hidden;
}

.graph-panel,
.note-panel,
.detective-panel {
  min-height: 0;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.app-shell.is-detective .explorer-shell {
  grid-template-columns:
    minmax(0, 1fr)
    12px
    minmax(320px, var(--note-panel-width))
    12px
    minmax(280px, var(--detective-panel-width));
}

.graph-panel {
  display: flex;
  flex-direction: column;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.graph-toolbar button,
.backlink-item,
.tag-button {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.graph-toolbar button {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
}

.toolbar-actions,
.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions {
  padding-right: 2px;
}

.toolbar-options {
  position: relative;
}

.toolbar-bookmarks {
  position: relative;
}

.toolbar-search {
  margin-left: auto;
  min-width: min(340px, 42vw);
  flex: 1 1 280px;
  justify-content: flex-end;
}

.toolbar-detective-actions[hidden] {
  display: none;
}

.toolbar-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  min-width: 220px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 24, 38, 0.97);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 12px;
}

.toolbar-popover[hidden] {
  display: none;
}

.toolbar-popover-section {
  display: grid;
  gap: 8px;
}

.toolbar-popover-heading {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.app-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(6, 16, 27, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 90ms ease, transform 90ms ease;
}

.app-tooltip[hidden] {
  display: block;
  visibility: hidden;
}

.app-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.app-tooltip-text {
  font-size: 0.86rem;
  line-height: 1.35;
  white-space: nowrap;
}

.app-tooltip-card {
  display: grid;
  gap: 8px;
}

.app-tooltip-title {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.15;
}

.app-tooltip-meta,
.app-tooltip-section-title,
.app-tooltip-layer-copy small {
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.35;
}

.app-tooltip-section-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-tooltip-layer-list {
  display: grid;
  gap: 6px;
}

.app-tooltip-layer-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.app-tooltip-layer-swatch {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--tooltip-layer-color, var(--accent-cool));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.app-tooltip-layer-swatch.is-canon {
  background: var(--accent);
}

.app-tooltip-layer-copy {
  display: grid;
  gap: 2px;
}

.app-tooltip-layer-copy strong {
  font-size: 0.83rem;
  line-height: 1.25;
}

.toolbar-icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.toolbar-tooltip-target {
  display: inline-flex;
}

.toolbar-icon-button:hover {
  transform: translateY(-1px);
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.toolbar-icon-button:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  transform: none;
}

.toolbar-icon-button.is-active {
  background: rgba(99, 216, 234, 0.16);
  border-color: rgba(99, 216, 234, 0.36);
}

.toolbar-icon-button.is-detective-toggle {
  background: rgba(255, 212, 107, 0.1);
  border-color: rgba(255, 212, 107, 0.26);
}

.toolbar-icon-button.is-detective-create {
  background: rgba(124, 227, 139, 0.12);
  border-color: rgba(124, 227, 139, 0.28);
}

.toolbar-icon-button.is-detective-node {
  background: rgba(99, 216, 234, 0.14);
  border-color: rgba(99, 216, 234, 0.3);
}

.toolbar-icon-button.is-detective-duplicate {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.toolbar-icon-button.is-detective-delete {
  background: rgba(255, 140, 107, 0.12);
  border-color: rgba(255, 140, 107, 0.28);
}

.toolbar-icon-button.is-detective-export {
  background: rgba(255, 212, 107, 0.12);
  border-color: rgba(255, 212, 107, 0.28);
}

.toolbar-icon-button.is-detective-import {
  background: rgba(195, 166, 255, 0.12);
  border-color: rgba(195, 166, 255, 0.28);
}

.toolbar-icon-button.is-detective-filter {
  background: rgba(255, 154, 213, 0.12);
  border-color: rgba(255, 154, 213, 0.28);
}

.toolbar-icon-button.is-detective-path {
  background: rgba(255, 212, 107, 0.12);
  border-color: rgba(255, 212, 107, 0.28);
}

.toolbar-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.toolbar-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-toolbar button:hover,
.backlink-item:hover,
.tag-button:hover {
  transform: translateY(-1px);
}

.graph-toolbar button:hover,
.backlink-item:hover {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.graph-toolbar button.is-active {
  background: rgba(99, 216, 234, 0.16);
  border-color: rgba(99, 216, 234, 0.36);
}

.toolbar-label {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.toolbar-select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.graph-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.graph-stats-badge {
  position: absolute;
  right: 16px;
  bottom: 14px;
  z-index: 6;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(6, 16, 27, 0.72);
  color: rgba(238, 246, 255, 0.88);
  font-size: 0.74rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  backdrop-filter: blur(10px);
  user-select: none;
  cursor: default;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.panel-resizer {
  position: relative;
  min-height: 0;
  cursor: col-resize;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(99, 216, 234, 0.08), rgba(255, 255, 255, 0));
}

.panel-resizer::after {
  content: "";
  position: absolute;
  inset: 50% 2px auto;
  height: 76px;
  transform: translateY(-50%);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.2) 0,
      rgba(255, 255, 255, 0.2) 2px,
      transparent 2px,
      transparent 6px
    );
}

.panel-resizer:hover::after,
.panel-resizer.is-dragging::after,
.panel-resizer:focus-visible::after {
  background:
    linear-gradient(180deg, rgba(255, 212, 107, 0.06), rgba(255, 212, 107, 0.22), rgba(255, 212, 107, 0.06)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.36) 0,
      rgba(255, 255, 255, 0.36) 2px,
      transparent 2px,
      transparent 6px
    );
}

.panel-resizer:focus-visible {
  outline: none;
}

.graph-context-menu {
  position: absolute;
  z-index: 10;
  min-width: 190px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 24, 38, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

.graph-context-menu[hidden] {
  display: none;
}

.graph-context-menu button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.graph-context-menu button:hover:not(:disabled) {
  background: rgba(99, 216, 234, 0.12);
}

.graph-context-menu button:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

.note-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.app-shell.is-detective .note-panel {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.detective-panel {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.detective-panel-resizer[hidden],
.detective-panel[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#search-input {
  width: 100%;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 11, 18, 0.92);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.note-panel-meta,
.empty-state,
.note-warning,
.backlinks-count {
  color: var(--text-dim);
}

#search-input:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 216, 234, 0.16);
}

.note-panel-meta {
  flex: 0 0 auto;
}

.investigator-tools {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.investigator-tools[hidden] {
  display: none;
}

.tool-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.tool-card-toolbar {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.layer-selector-row,
.tool-inline-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-stack {
  display: grid;
  gap: 8px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.layer-row.is-active {
  background: rgba(255, 255, 255, 0.05);
}

.layer-row.is-canon {
  opacity: 0.96;
}

.layer-visibility-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  cursor: pointer;
}

.layer-rename-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  cursor: pointer;
}

.layer-visibility-button.is-visible {
  color: var(--accent);
  border-color: rgba(255, 212, 107, 0.28);
  background: rgba(255, 212, 107, 0.08);
}

.layer-rename-button:hover {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
  color: var(--text);
}

.layer-visibility-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.layer-visibility-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.layer-rename-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.layer-rename-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-select-button {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: var(--layer-color-soft, rgba(255, 255, 255, 0.08));
  color: var(--layer-text, var(--text));
  text-align: left;
  cursor: pointer;
}

.layer-select-button.is-static {
  cursor: default;
}

.layer-row.is-active .layer-select-button {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.72),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

.layer-select-button.is-canon {
  background: linear-gradient(135deg, rgba(238, 246, 255, 0.18), rgba(150, 172, 192, 0.28));
  color: var(--text);
}

.layer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.layer-selector-row select,
.tool-inline-group input {
  min-width: 0;
  flex: 1 1 auto;
}

.layer-name-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 11, 18, 0.82);
  color: var(--text);
}

.layer-name-input:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 216, 234, 0.12);
}

.toolbar-bookmarks-panel {
  right: 0;
  min-width: min(360px, calc(100vw - 32px));
  max-width: min(400px, calc(100vw - 32px));
}

.toolbar-bookmark-list {
  display: grid;
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
}

.toolbar-bookmark-item {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.toolbar-bookmark-item.is-current .toolbar-bookmark-open {
  border-color: rgba(255, 212, 107, 0.3);
  background: rgba(255, 212, 107, 0.1);
}

.toolbar-bookmark-open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.toolbar-bookmark-open strong,
.toolbar-bookmark-open small {
  display: block;
}

.toolbar-bookmark-open small {
  margin-top: 4px;
  color: var(--text-dim);
}

.toolbar-bookmark-open:hover,
.toolbar-bookmark-remove:hover {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.toolbar-bookmark-remove {
  width: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
}

.layer-context-menu {
  position: absolute;
  z-index: 30;
  min-width: 168px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 24, 38, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

.layer-context-menu[hidden] {
  display: none;
}

.layer-context-menu button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.layer-context-menu button:hover {
  background: rgba(99, 216, 234, 0.12);
}

.tool-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.tool-block + .tool-block {
  margin-top: 16px;
}

.tool-action-button,
.mini-button,
.bookmark-open,
.saved-item-open {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.tool-action-button:hover,
.mini-button:hover,
.bookmark-open:hover,
.saved-item-open:hover {
  transform: translateY(-1px);
}

.tool-action-button,
.mini-button {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
}

.tool-action-button:hover,
.mini-button:hover,
.bookmark-open:hover,
.saved-item-open:hover {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.tool-action-button.is-active,
.mini-button.is-active {
  background: rgba(255, 212, 107, 0.14);
  border-color: rgba(255, 212, 107, 0.34);
}

.tool-action-button:disabled,
.mini-button:disabled {
  opacity: 0.54;
  cursor: not-allowed;
  transform: none;
}

.tool-empty,
.path-summary,
.shared-neighbors-label,
.path-focus-toggle {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.bookmark-list {
  display: grid;
  gap: 8px;
  max-height: 188px;
  overflow: auto;
}

.bookmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bookmark-item.is-current {
  border-color: rgba(255, 212, 107, 0.28);
  background: rgba(255, 212, 107, 0.07);
}

.bookmark-open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}

.saved-item-list {
  display: grid;
  gap: 8px;
  max-height: 188px;
  overflow: auto;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.saved-item.is-active {
  border-color: rgba(99, 216, 234, 0.28);
  background: rgba(99, 216, 234, 0.08);
}

.saved-item-open {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}

.saved-item-open strong,
.bookmark-open strong {
  display: block;
  font-weight: 600;
}

.saved-item-open small,
.bookmark-open small {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
}

.bookmark-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.mini-button {
  padding: 8px 10px;
  font-size: 0.78rem;
}

.path-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.path-focus-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.path-node-list,
.shared-neighbor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.path-node-chip {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 212, 107, 0.28);
  background: rgba(255, 212, 107, 0.1);
  color: var(--text);
  cursor: pointer;
}

.path-separator {
  display: inline-flex;
  align-items: center;
  color: var(--text-dim);
}

.shared-neighbors {
  margin-top: 12px;
}

.shared-neighbors-label {
  margin-bottom: 8px;
}

.tool-status {
  min-height: 1.2em;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.investigation-notes {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 11, 18, 0.82);
  color: var(--text);
  line-height: 1.5;
}

.investigation-notes:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 216, 234, 0.14);
}

.note-panel-meta:empty {
  display: none;
}

.note-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.app-shell:not(.is-exploring) .note-content,
.app-shell:not(.is-exploring) .note-panel-meta {
  display: none;
}

.note-content a {
  color: var(--accent);
}

.empty-state,
.backlinks-section {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.backlinks-section {
  margin-bottom: 18px;
}

.backlinks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.backlinks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.backlink-item {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
}

.backlink-item small {
  color: var(--text-dim);
  white-space: nowrap;
}

.backlink-item.is-current {
  border-color: rgba(255, 212, 107, 0.34);
  background: rgba(255, 212, 107, 0.08);
}

.meta-label {
  display: block;
  margin-bottom: 10px;
  color: var(--accent-cool);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.note-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.tag-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(99, 216, 234, 0.12);
  border: 1px solid rgba(99, 216, 234, 0.22);
  color: var(--text);
  font-size: 0.78rem;
}

.tag.alias {
  background: rgba(255, 212, 107, 0.08);
  border-color: rgba(255, 212, 107, 0.22);
}

.tag-button.is-active {
  background: rgba(255, 212, 107, 0.14);
  border-color: rgba(255, 212, 107, 0.34);
}

.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4 {
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.note-body h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 2.1rem;
}

.note-body h2 {
  margin-top: 28px;
  font-size: 1.45rem;
}

.note-body p,
.note-body li {
  color: #e1edf8;
  line-height: 1.72;
}

.note-body ul,
.note-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.note-body li {
  padding-left: 4px;
}

.note-body li + li {
  margin-top: 6px;
}

.note-body li > ul,
.note-body li > ol {
  margin-top: 8px;
  margin-bottom: 0;
}

.note-body li::marker {
  color: rgba(225, 237, 248, 0.7);
}

.note-date {
  color: var(--accent-cool);
  font-style: italic;
}

.note-meta,
.note-aliases {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.note-references {
  margin-bottom: 18px;
}

.note-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reference-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(225, 237, 248, 0.86);
  font-size: 0.78rem;
  text-decoration: none;
}

.reference-link:hover,
.reference-link:focus-visible {
  border-color: rgba(99, 216, 234, 0.32);
  background: rgba(99, 216, 234, 0.08);
  color: var(--text);
}

.note-meta-stack {
  display: grid;
  gap: 12px;
  padding: 14px 0 6px;
}

.search-completions-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-completions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-completions-header small {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.search-completions-list {
  display: grid;
  gap: 8px;
}

.search-completion-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.search-completion-item:hover {
  transform: translateY(-1px);
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.search-completion-item.is-selected {
  background: rgba(99, 216, 234, 0.16);
  border-color: rgba(99, 216, 234, 0.34);
}

.search-completion-item.is-active {
  background: rgba(255, 212, 107, 0.1);
  border-color: rgba(255, 212, 107, 0.28);
}

.search-completion-item strong,
.search-completion-item small {
  display: block;
}

.search-completion-item small {
  margin-top: 4px;
  color: var(--text-dim);
}

.graph-filter-toolbar {
  padding: 0 12px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.graph-filter-toolbar-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.graph-filter-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}

.graph-filter-toolbar-input {
  width: 240px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.graph-filter-toolbar-input::placeholder {
  color: var(--text-dim);
}

.graph-filter-toolbar-input:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.34);
  box-shadow: 0 0 0 3px rgba(99, 216, 234, 0.12);
}

.graph-filter-pill {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  max-width: 240px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.graph-filter-pill.is-show {
  border-color: rgba(99, 216, 234, 0.3);
  background: rgba(99, 216, 234, 0.12);
}

.graph-filter-pill.is-hide {
  border-color: rgba(255, 140, 107, 0.32);
  background: rgba(255, 140, 107, 0.12);
}

.graph-filter-pill-toggle,
.graph-filter-pill-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.graph-filter-pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 12px;
  height: 40px;
  color: var(--text);
}

.graph-filter-pill-toggle:hover,
.graph-filter-pill-remove:hover {
  background: rgba(255, 255, 255, 0.08);
}

.graph-filter-pill-toggle span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-filter-pill-remove {
  width: 34px;
  height: 40px;
  font-size: 1rem;
  color: var(--text-dim);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.graph-filter-pill-eye {
  position: relative;
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: currentColor;
}

.graph-filter-pill-eye svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.graph-filter-pill-eye.is-hidden::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 7px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-35deg);
  transform-origin: center;
}

.note-inline-meta {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
}

.note-meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  font-size: 0.76rem;
}

.note-backlinks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.note-title-row h1 {
  margin: 0;
}

.note-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.note-title-actions .toolbar-icon svg {
  stroke-width: initial;
}

.bookmark-icon svg {
  width: 100%;
  height: 100%;
}

.bookmark-icon.is-outline svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bookmark-icon.is-filled svg {
  fill: currentColor;
  stroke: none;
}

.note-backlinks-section {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.note-backlinks-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.note-backlinks-summary::-webkit-details-marker {
  display: none;
}

.note-backlinks-summary small {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.note-backlinks-panel {
  margin-top: 12px;
}

.investigation-note-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.investigation-note-card-header,
.investigation-note-actions,
.custom-node-fields {
  display: flex;
  gap: 10px;
}

.investigation-note-card-header {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.investigation-note-actions {
  align-items: center;
  flex-wrap: wrap;
}

.custom-node-card {
  margin-bottom: 18px;
}

.custom-node-fields {
  flex-direction: column;
}

.custom-node-field {
  display: grid;
  gap: 6px;
}

.custom-node-field input,
.investigation-note-editor {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 11, 18, 0.82);
  color: var(--text);
}

.custom-node-field input:focus,
.investigation-note-editor:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 216, 234, 0.12);
}

.investigation-note-editor {
  min-height: 170px;
  resize: vertical;
  line-height: 1.55;
}

.note-link-picker {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.note-link-selection {
  display: grid;
  gap: 6px;
}

.note-link-selection-text {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 212, 107, 0.08);
  border: 1px solid rgba(255, 212, 107, 0.18);
  color: var(--text);
  line-height: 1.45;
}

.note-link-result-list {
  display: grid;
  gap: 8px;
}

.note-link-result {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.note-link-result small {
  color: var(--text-dim);
}

.note-link-result-create {
  border-color: rgba(124, 227, 139, 0.24);
  background: rgba(124, 227, 139, 0.08);
}

.investigation-note-preview {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(3, 11, 18, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.investigation-note-preview p,
.investigation-note-preview li {
  color: #e1edf8;
  line-height: 1.7;
}

.investigation-note-preview ul {
  margin: 0;
  padding-left: 22px;
}

.note-inline-image {
  display: block;
  width: min(100%, 560px);
  height: auto;
  margin: 18px 0;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(3, 11, 18, 0.82);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .explorer-shell {
    min-height: calc(100vh - 28px);
    min-height: calc(100dvh - 28px);
    grid-template-columns: 1fr;
    gap: 14px;
    overflow: visible;
  }

  .app-shell.is-detective .explorer-shell {
    grid-template-columns: 1fr;
  }

  .panel-resizer {
    display: none;
  }

  .graph-panel,
  .note-panel,
  .detective-panel {
    border-radius: var(--radius-lg);
  }

  .tool-card-header,
  .bookmark-item,
  .saved-item,
  .layer-selector-row,
  .layer-name-row,
  .tool-inline-group {
    flex-direction: column;
    align-items: stretch;
  }

  .layer-row {
    align-items: stretch;
  }

  .tool-card-header-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .path-controls {
    grid-template-columns: 1fr;
  }

  .bookmark-actions {
    width: 100%;
  }

  .bookmark-actions .mini-button,
  .tool-action-button,
  .path-node-chip {
    width: 100%;
  }

  .graph-stage {
    min-height: 48vh;
  }
}

/* Detective Panel Search */
.detective-node-search {
  display: grid;
  gap: 4px;
}

.detective-node-search-label {
  font-size: 0.76rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detective-node-search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.detective-node-search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 11, 18, 0.82);
  color: var(--text);
  font-size: 0.88rem;
}

.detective-node-search-input:focus {
  outline: none;
  border-color: rgba(99, 216, 234, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 216, 234, 0.12);
}

.detective-node-search-clear {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.detective-node-search-clear:hover {
  background: rgba(255, 140, 107, 0.15);
  border-color: rgba(255, 140, 107, 0.3);
  color: var(--text);
}

.detective-node-search-results {
  display: grid;
  gap: 4px;
  max-height: 180px;
  overflow: auto;
  background: rgba(6, 16, 27, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px;
  z-index: 20;
}

.detective-search-result {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.detective-search-result:hover,
.detective-search-result.is-selected {
  background: rgba(99, 216, 234, 0.12);
  border-color: rgba(99, 216, 234, 0.28);
}

.detective-search-result small {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.detective-search-no-results {
  padding: 8px 10px;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-align: center;
}
