@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --accent: #f42365;
  --accent-dark: #d01950;
  --accent-light: #ff4d7d;
  --accent-glow: rgba(244, 35, 101, 0.4);
  --bg: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --text: #ffffff;
  --text-secondary: #888888;
  --text-tertiary: #555555;
  --text-on-accent: #ffffff; /* Accessible text color for accent backgrounds */
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --node-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  --glow-shadow: 0 0 80px rgba(244, 35, 101, 0.3);
  --bg-accent-glow: rgba(244, 35, 101, 0.1);
  --bg-accent-light: rgba(255, 77, 125, 0.05);
}

/* Metal Blue Theme - Modern blue-tinted dark grays */
[data-theme="metal"] {
  --accent: #f42365;
  --accent-dark: #d01950;
  --accent-light: #ff4d7d;
  --accent-glow: rgba(244, 35, 101, 0.4);
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1f2937;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --text-on-accent: #ffffff; /* Accessible text color for accent backgrounds */
  --border: rgba(139, 148, 158, 0.12);
  --border-light: rgba(139, 148, 158, 0.2);
  --node-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  --glow-shadow: 0 0 80px rgba(244, 35, 101, 0.35);
  --bg-accent-glow: rgba(244, 35, 101, 0.08);
  --bg-accent-light: rgba(255, 77, 125, 0.04);
}

body {
  font-family: "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for mobile */
  position: relative;
  user-select: none;
  /* Prevent text selection on mobile */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Animated background */
.bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
      ellipse at bottom right,
      var(--bg-accent-glow) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at top left,
      var(--bg-accent-light) 0%,
      transparent 50%
    ),
    var(--bg);
  z-index: 0;
}

.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

/* Floating particles */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, var(--accent-light), transparent);
  border-radius: 50%;
  pointer-events: none;
  animation: floatParticle 20s infinite linear;
}

@keyframes floatParticle {
  from {
    transform: translateY(100vh) translateX(0) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.3;
  }
  to {
    transform: translateY(-100px) translateX(100px) scale(1.5);
    opacity: 0;
  }
}

/* Canvas */
.canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 30000px;
  height: 30000px;
  z-index: 2;
  cursor: grab;
  transition: transform 0.1s ease-out;

  /* Improve mobile handling */
  will-change: transform;
  /* Ensure proper rendering on mobile */
  transform-origin: 0 0;
}

/* Subtle canvas background pattern - behind everything */
.canvas::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;

  /* Grid pattern for spatial awareness */
  background:
    radial-gradient(circle at center, var(--border) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, var(--accent) 3px, transparent 4px);
  background-size:
    50px 50px,
    100% 100%;
  background-repeat:
    repeat,
    no-repeat;
  opacity: 0.15;
}

.canvas:active {
  cursor: grabbing;
}

.svg-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.connection-line {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  opacity: 0.6;
  filter: drop-shadow(0 0 10px var(--accent-glow));
  stroke-dasharray: 5, 5;
  animation: dashMove 1s linear infinite;
  pointer-events: none;
}

@keyframes dashMove {
  to {
    stroke-dashoffset: -10;
  }
}

.connection-arrow {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 10;
}

.connection-line.active {
  stroke-width: 3;
  opacity: 1;
  filter: drop-shadow(0 0 20px var(--accent));
}

.connection-line.inactive {
  stroke: var(--text-tertiary);
  stroke-width: 1;
  opacity: 0.3;
  filter: none;
}

/* Arrow marker styling */
.svg-connections marker path {
  transition: fill 0.2s ease;
}

.svg-connections marker#arrow path {
  fill: var(--accent);
}

.svg-connections marker#arrow-active path {
  fill: var(--accent);
}

.svg-connections marker#arrow-inactive path {
  fill: var(--text-tertiary);
}

/* Toolbar */
.toolbar {
  max-height: 50px;
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 15px;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.toolbar .tool-btn-compact {
  padding: 8px 10px;
  min-width: 44px;
  max-width: 44px;
}

/* Hide duplicate board management buttons on desktop (they're in the board-selector on the left) */
.toolbar > .tool-btn:nth-last-child(1), /* Delete Board */
.toolbar > .tool-btn:nth-last-child(2), /* Flip All (compact) */
.toolbar > .tool-btn:nth-last-child(3) { /* Rename Board */
  display: none;
}

/* Show the board-selector on desktop */
.toolbar .board-selector {
  display: flex;
}

.toolbar .board-actions {
  display: flex;
}

.tool-btn {
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  max-height: 28px;
}

.tool-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-glow),
    transparent
  );
  transition: left 0.5s ease;
}

.tool-btn:hover::before {
  left: 100%;
}

.tool-btn:hover {
  background: var(--accent);
  color: var(--text-on-accent);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px var(--accent-glow);
  border-color: var(--accent);
}

.tool-btn.active {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.tool-icon {
  width: 16px;
  height: 16px;
}

/* Nodes */
.node {
  position: absolute;
  min-width: 200px;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  cursor: move;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--node-shadow);
  z-index: 10;
  overflow: visible;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.node.dragging {
  z-index: 1000;
  transform: scale(1.05);
  box-shadow: var(--glow-shadow), var(--node-shadow);
  border-color: var(--accent);
  transition: none;
}

.node.editing {
  z-index: 1000;
}

/* Group dragging feedback */
.node.selected.dragging {
  border-color: var(--accent-light);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6),
              0 0 0 3px var(--accent-glow),
              0 0 40px var(--accent-glow);
}

.node.selected.dragging::after {
  background: var(--accent-light);
  box-shadow: 0 0 10px var(--accent-glow);
}

.node:hover {
  border-color: var(--border-light);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9);
}

.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow), 0 0 80px var(--accent-glow),
    var(--node-shadow);
}

.node.selected::after {
  content: '';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 50%;
  z-index: 10;
}

.node-header {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 8px;
  cursor: move;
  user-select: none;
  border-radius: 16px 16px 0 0;
  position: relative;
  align-items: center;
}

.node-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--node-accent, var(--accent)), transparent);
  opacity: 0.4;
}

.node-type {
  font-size: 1.7rem;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;

  /* Ellipsize long titles */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
  min-height: 1.9rem;
  /* Grid placement: first row, first column */
  grid-column: 1;
  grid-row: 1;
  /* Set a reasonable min-width and max-width */
  min-width: 60px;
  max-width: 340px;
}

.node-type:hover {
  background-color: rgba(var(--accent), 0.1);
}

.node-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  margin-right: 6px;
  opacity: 0.85;
  flex-shrink: 0;
}

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

.node-type-label {
  display: inline-block;
}

.node-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  /* Grid placement: first row, second column */
  grid-column: 2;
  grid-row: 1;
  /* Align to the right */
  justify-self: end;
}

.node:hover .node-actions {
  opacity: 1;
}

.node-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.node-btn:hover {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

.node-content {
  padding: 20px;
  max-width: 500px;
  max-height: 600px;
  overflow-y: auto;
}

.node-content:has(.text-editor.CodeMirror) {
  padding-left: 8px;
  padding-right:8px;
}

.node-card-shell {
  position: relative;
  perspective: 1400px;
}

.node-card-inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  width: 100%;
  height: 100%;
}

.node-card-face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  border-radius: 0 0 16px 16px;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.node-card-back {
  transform: rotateY(180deg);
}

.node.showing-result .node-card-inner {
  transform: rotateY(180deg);
}

.node-result-content {
  background: var(--bg-secondary);
}

.empty-result {
  color: var(--text-secondary);
  font-style: italic;
}

.node-card-front {
  pointer-events: auto;
}

.node.showing-result .node-card-front {
  pointer-events: none;
}

.node.showing-result .node-card-back {
  pointer-events: auto;
}

.node-type-editor {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 1.7rem;
  padding: 2px 4px;
  margin: 0;

  /* Width is set via JS to match original title */
  /* Match node-type flex behavior */
  flex: 0 0 auto;
  outline: none;
  box-sizing: border-box;
}

.node.custom-theme .node-type-editor {
  border-color: var(--node-accent);
  color: var(--node-accent);
}

/* Markdown content styling */
.markdown-content {
  color: var(--text);
  line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 0;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: white;
}

.markdown-content h1 {
  font-size: 2em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}

.markdown-content h2 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}

.markdown-content h3 {
  font-size: 1.25em;
}
.markdown-content h4 {
  font-size: 1em;
}
.markdown-content h5 {
  font-size: 0.875em;
}
.markdown-content h6 {
  font-size: 0.85em;
  color: var(--text-secondary);
}

.markdown-content p {
  margin-bottom: 16px;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0 0 16px 1.25em;
  padding-left: 1.25em;
  list-style-position: outside;
}

.markdown-content ul {
  list-style: disc;
}

.markdown-content ol {
  list-style: decimal;
}

.markdown-content ul > li {
  margin-bottom: 8px;
  padding-left: 0;
  position: list-item;
  color: var(--text);
}

.markdown-content ul > li::before {
  content: none;
}

.markdown-content ol > li {
  margin-bottom: 8px;
  padding-left: 0;
  position: list-item;
  color: var(--text);
}

.markdown-content ol > li::before {
  content: none;
}

/* Nested lists - add proper indentation and reset styling */
.markdown-content li > ul,
.markdown-content li > ol {
  margin-top: 8px;
  margin-bottom: 8px;
  padding-left: 20px;
}

.markdown-content blockquote {
  margin: 0 0 16px;
  padding: 0 1em;
  border-left: 4px solid var(--accent);
  color: var(--text-secondary);
}

.markdown-content code {
  background: var(--bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 85%;
  color: var(--accent-light);
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.markdown-content pre {
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.markdown-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 16px;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
}

.markdown-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.markdown-content a {
  color: var(--accent-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.markdown-content a:hover {
  border-bottom-color: var(--accent-light);
}

.markdown-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Checkbox styling for task lists */
.markdown-content input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

/* Checkbox color for nodes with custom theme */
.node.custom-theme .markdown-content input[type="checkbox"] {
  accent-color: var(--node-accent);
}

/* Text editor that matches content area exactly */
.text-editor {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  resize: none;
  padding: 8px;
  margin: 0;
  min-height: 150px;
}

/* Inline CodeMirror editor styling */
.text-editor.CodeMirror {
  width: 100% !important;
  max-width: 100% !important;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  height: auto;
  font-family: "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: inherit;
  line-height: 1.7;
  color: var(--text);
  box-sizing: border-box;
}

.text-editor.CodeMirror .CodeMirror-scroll {
  min-height: 100px;
  max-height: none;
  padding: 0;
  overflow: visible !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

.text-editor.CodeMirror .CodeMirror-vscrollbar,
.text-editor.CodeMirror .CodeMirror-hscrollbar,
.text-editor.CodeMirror .CodeMirror-scrollbar-filler {
  display: none !important;
}

.text-editor.CodeMirror .CodeMirror-cursor {
  border-left-color: var(--node-accent, var(--accent));
}

.text-editor.CodeMirror .CodeMirror-selected {
  background: var(--node-accent-glow, var(--accent-glow));
}

.text-editor.CodeMirror .CodeMirror-line {
  font-family: "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: inherit;
  line-height: 1.7;
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
}

.text-editor.CodeMirror .CodeMirror-lines {
  padding: 0;
}

.text-editor.CodeMirror .CodeMirror-sizer {
  margin-bottom: 0 !important;
  border-right-width: 0 !important;
  padding-right: 0 !important;
  padding-bottom: 50px !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.text-editor.CodeMirror pre.CodeMirror-line,
.text-editor.CodeMirror pre.CodeMirror-line-like {
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
}

/* Override CodeMirror header styles to match rendered markdown */
.text-editor.CodeMirror .cm-header-1 {
  font-size: 2em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

.text-editor.CodeMirror .cm-header-2 {
  font-size: 1.5em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

.text-editor.CodeMirror .cm-header-3 {
  font-size: 1.25em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

.text-editor.CodeMirror .cm-header-4 {
  font-size: 1em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

.text-editor.CodeMirror .cm-header-5 {
  font-size: 0.875em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

.text-editor.CodeMirror .cm-header-6 {
  font-size: 0.85em !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
}

/* Text content styling */
.text-content {
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* Drag line for connections */
.drag-line {
  stroke: var(--accent);
  stroke-width: 3;
  fill: none;
  opacity: 0.9;
  filter: drop-shadow(0 0 15px var(--accent-glow));
  stroke-dasharray: 8, 4;
  animation: dashMove 0.8s linear infinite;
  pointer-events: none;
}

/* Cut line for cutting connections */
.cut-line {
  stroke: #ff4444;
  stroke-width: 2;
  fill: none;
  opacity: 0.8;
  filter: drop-shadow(0 0 10px rgba(255, 68, 68, 0.6));
  stroke-dasharray: 3, 3;
  animation: dashMove 0.5s linear infinite;
  pointer-events: none;
}

/* Connection mode visual feedback */
.node-content:hover {
  cursor: grab;
}

.node-content:active {
  cursor: grabbing;
}

/* Instructions */
.instructions {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 8px 10px;
  z-index: 1000;
  font-size: 10px;
  color: var(--text-tertiary);
  opacity: 0.6;
}

.instruction-item {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.instruction-item:last-child {
  margin-bottom: 0;
}

.key {
  background: rgba(26, 26, 26, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 30px;
  text-align: center;
}

/* Theme Selector */
.theme-selector {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  min-width: 400px;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  z-index: 3000;
  overflow: hidden;
}

.theme-selector-header {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.theme-selector-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
  transform: scale(1.1);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 15px;
  padding: 25px;
  max-height: 400px;
  overflow-y: auto;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  background: var(--bg-tertiary);
}

.theme-option:hover {
  transform: translateY(-3px);
  background: var(--bg-secondary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.theme-option.active {
  border-color: var(--accent);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.theme-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.theme-option:hover .theme-preview {
  transform: scale(1.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.theme-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: color 0.2s ease;
}

.theme-option:hover .theme-name,
.theme-option.active .theme-name {
  color: var(--text);
}

/* Custom node theming */
.node.custom-theme .node-type {
  color: var(--node-accent);
}

.node.custom-theme .node-btn:hover {
  background: var(--node-accent);
  border-color: var(--node-accent);
}

.node.custom-theme.selected {
  border-color: var(--node-accent);
  box-shadow: 0 0 0 2px var(--node-accent-glow), 0 0 80px var(--node-accent-glow), var(--node-shadow);
}

.node.custom-theme .node-type:hover {
  background-color: var(--node-accent-glow);
}

.node.custom-theme:hover {
  border-color: var(--node-accent-light);
}

.node.custom-theme.dragging {
  border-color: var(--node-accent);
  box-shadow: 0 0 80px var(--node-accent-glow), var(--node-shadow);
}

/* Custom node markdown theming */
.node.custom-theme .markdown-content h1,
.node.custom-theme .markdown-content h2,
.node.custom-theme .markdown-content h3,
.node.custom-theme .markdown-content h4,
.node.custom-theme .markdown-content h5,
.node.custom-theme .markdown-content h6 {
  color: var(--text);
}

.node.custom-theme .markdown-content code {
  color: var(--node-accent-light);
}

.node.custom-theme .markdown-content blockquote {
  border-left-color: var(--node-accent);
}

.node.custom-theme .markdown-content a {
  color: var(--node-accent-light);
}

.node.custom-theme .markdown-content a:hover {
  border-bottom-color: var(--node-accent-light);
}

.node.custom-theme .markdown-content ul li::before {
  color: var(--node-accent);
}

.node.custom-theme .markdown-content ol li::before {
  color: var(--node-accent);
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 180px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: none;
}

.context-menu.show {
  display: block;
}

.context-item {
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.context-item:hover {
  background: var(--accent);
  color: var(--text-on-accent);
}

.context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.6);
}

/* Hide mobile menu buttons on desktop */
.mobile-menu-btn,
.board-menu-btn {
  display: none;
}

.board-menu {
  display: none;
}

/* Performance optimization: Hide content during zoom transforms */
/* Reduce node complexity during transforms */
.canvas.transforming .node {
  box-shadow: none !important;
}

.canvas.transforming .node-content {
  /* Hide content during zoom for better performance */
  visibility: hidden;
}

.canvas.transforming .node::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.canvas.zoomed-out .node::after {
  content: none;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    /* Prevent rubber band scrolling on iOS */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Prevent zooming */
    touch-action: pan-x pan-y;
  }

  /* Fix rendering glitches on mobile */
  * {
    /* Disable blue highlight on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;

    /* Fix rendering issues */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
  }

  /* Re-enable text selection for content areas */
  .node-content,
  input,
  textarea {
    -webkit-user-select: text;
    user-select: text;
  }

  /* Canvas mobile fixes */
  .canvas {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    will-change: transform;
    /* Improve rendering performance */
    contain: layout style paint;
  }

  /* Node mobile rendering fixes */
  .node {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Improve rendering performance */
    contain: layout style paint;
    will-change: transform;
  }

  /* SVG connections mobile fix */
  .svg-connections {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    pointer-events: none;
    /* Improve rendering */
    will-change: contents;
  }

  /* Hide desktop toolbar at top - only show as bottom popup menu */
  .toolbar {
    top: auto !important;
    left: auto !important;
    transform: none !important;
    position: fixed !important;
  }

  /* Hide instructions panel on mobile */
  .instructions {
    display: none !important;
  }

  /* Board menu button - Subtle Bottom Left */
  .board-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 1001;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    touch-action: manipulation;
  }

  .board-menu-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
  }

  .board-menu-btn:active {
    transform: scale(0.95);
    background: rgba(26, 26, 26, 0.95);
  }

  /* Highlight button when menu is open */
  .board-menu.mobile-open ~ .board-menu-btn {
    background: var(--bg-secondary);
    border-color: var(--accent);
  }

  .board-menu.mobile-open ~ .board-menu-btn svg {
    color: var(--accent);
  }

  /* Board Menu on mobile - Bottom Left Menu */
  .board-menu {
    display: none;
    position: fixed;
    bottom: 72px;
    left: 16px;
    right: auto !important;
    transform: none !important;
    width: 200px !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 1002 !important;

    /* Vertical layout */
    flex-direction: column !important;
    gap: 0 !important;
    padding: 0 !important;
    border-radius: 12px !important;

    /* Subtle styling */
    background: rgba(26, 26, 26, 0.92) !important;
    backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;

    /* Fade in animation */
    opacity: 0;
    transform-origin: bottom left;
    animation: fadeSlideInLeft 0.2s ease forwards;

    touch-action: manipulation;
    overflow: hidden;
  }

  @keyframes fadeSlideInLeft {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  /* Show board menu when open */
  .board-menu.mobile-open {
    display: flex !important;
  }

  .board-menu-header {
    padding: 12px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .board-menu-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px;
    max-height: 300px;
    overflow-y: auto;
  }

  .board-menu-item {
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
  }

  .board-menu-item:active {
    background: transparent;
    transform: scale(0.96);
    opacity: 0.7;
  }

  .board-menu-item.active {
    color: var(--accent);
    font-weight: 500;
  }

  /* Mobile hamburger menu button - Subtle Bottom Right */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    z-index: 1001;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    touch-action: manipulation;
  }

  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
  }

  .mobile-menu-btn:active {
    transform: scale(0.95);
    background: rgba(26, 26, 26, 0.95);
  }

  /* Highlight button when menu is open */
  .toolbar.mobile-open ~ .mobile-menu-btn {
    background: var(--bg-secondary);
    border-color: var(--accent);
  }

  .toolbar.mobile-open ~ .mobile-menu-btn svg {
    color: var(--accent);
  }

  /* Toolbar on mobile - Bottom Right Menu */
  .toolbar {
    /* Hidden by default */
    display: none;
    position: fixed;
    bottom: 72px;
    right: 16px;
    left: auto !important;
    transform: none !important;
    width: 200px !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 1002 !important;

    /* Vertical layout */
    flex-direction: column !important;
    gap: 4px !important;
    padding: 6px !important;
    border-radius: 12px !important;

    /* Subtle styling */
    background: rgba(26, 26, 26, 0.92) !important;
    backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;

    /* Fade in animation */
    opacity: 0;
    transform-origin: bottom right;
    animation: fadeSlideInRight 0.2s ease forwards;

    touch-action: manipulation;
  }

  @keyframes fadeSlideInRight {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  /* Show toolbar when open */
  .toolbar.mobile-open {
    display: flex !important;
    min-height: fit-content;
  }

  .tool-btn {
    /* Compact buttons with text */
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    padding: 12px 14px !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    transition: all 0.15s ease !important;
  }

  .tool-btn:active {
    background: transparent !important;
    transform: scale(0.96);
    opacity: 0.7;
  }

  .tool-btn .tool-text {
    display: inline !important;
    font-size: 14px !important;
    font-weight: 400;
    color: var(--text-secondary);
  }

  .tool-btn .tool-icon {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    color: var(--text-secondary);
  }

  /* Hide Clear button on mobile */
  .toolbar .tool-btn:nth-child(3) { /* Clear */
    display: none !important;
  }

  /* Show board management buttons on mobile (hidden on desktop) */
  .toolbar .tool-btn:nth-last-child(1), /* Delete Board */
  .toolbar .tool-btn:nth-last-child(2), /* Flip All (compact) */
  .toolbar .tool-btn:nth-last-child(3) { /* Rename Board */
    display: flex !important;
  }

  /* Theme Selector Mobile Optimization */
  .theme-selector {
    min-width: 90vw !important;
    max-width: 90vw !important;
    border-radius: 20px !important;
  }

  .theme-selector-header {
    padding: 16px 20px !important;
  }

  .theme-selector-header h3 {
    font-size: 16px !important;
  }

  .theme-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)) !important;
    gap: 12px !important;
    padding: 20px !important;
  }

  .theme-option {
    padding: 10px !important;
  }

  .theme-color {
    width: 36px !important;
    height: 36px !important;
  }

  .theme-name {
    font-size: 12px !important;
  }

  /* Board Selector Mobile - Hide it completely */
  .toolbar .board-selector {
    display: none !important;
  }

  .toolbar .board-actions {
    display: none !important;
  }

  .node {
    min-width: 150px;
    /* Improve touch interaction */
    touch-action: none;
  }

  /* Show fullscreen and theme buttons on mobile */
  .node-actions .node-btn {
    display: flex !important;
  }

  .node-content {
    /* Better touch scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Fix canvas boundaries on mobile */
  .canvas {
    /* Prevent overscroll and improve touch handling */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    /* Ensure nodes aren't clipped at edges */
    overflow: visible;
  }

  /* Mobile-specific node improvements */
  .node {
    /* Ensure nodes are always fully visible */
    z-index: 100;
    /* Prevent clipping */
    overflow: visible;
  }

  /* Ensure node content is properly contained but not clipped */
  .node-content {
    /* Better handling of content overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Improve instructions positioning on mobile */
  .instructions {
    bottom: 10px;
    right: 10px;
    font-size: 9px;
    padding: 6px 8px;
    /* Make it more transparent on mobile to avoid clutter */
    opacity: 0.4;
  }
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -20px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes subtleShake {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(1px); }
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 0);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -20px);
    opacity: 0;
  }
}

/* Board selector */
.board-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 20px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}

.board-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.board-dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 6px 12px;
  font-size: 14px;
  min-width: 160px;
  max-height: 28px;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  
  /* Add these: */
  display: flex;
  align-items: center;
  
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

.board-dropdown:hover {
  border-color: var(--accent);
}

.board-dropdown:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.new-board-btn {
  white-space: nowrap;
  min-width: fit-content;
  max-height: 28px;
}

.new-board-btn .tool-text {
  white-space: nowrap;
}

.small-btn {
  padding: 10px 6px !important;
  min-width: 32px !important;
  max-height: 28px;
}

.small-btn .tool-text {
  display: none;
}

.small-icon {
  width: 16px !important;
  height: 16px !important;
}

/* Export dialog */
.export-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.export-dialog-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 400px;
  max-width: 500px;
}

.export-dialog h3 {
  color: var(--text);
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.export-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
}

.export-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.export-btn small {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
  font-weight: normal;
}

.export-cancel {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.export-cancel:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Fullscreen overlay for maximized nodes */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.fullscreen-overlay.active {
  opacity: 1;
  visibility: visible;
}


.maximized-node {
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90vw;
  height: 85vh;
  max-width: 1200px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fullscreen-overlay.active .maximized-node {
  transform: scale(1);
}

.maximized-header {
  padding: 20px 30px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.maximized-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.maximized-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.maximize-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.maximize-btn:hover {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.close-maximize-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.close-maximize-btn:hover {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

.maximized-content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 18px;
  line-height: 1.8;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  outline: none;
  cursor: default;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  background-color: var(--bg-secondary);
}

.maximized-content::-webkit-scrollbar {
  width: 12px;
}

.maximized-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}

.maximized-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

.maximized-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

.maximized-content .markdown-content {
  max-width: 800px;
  margin: 0 auto;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

/* Maximized editor styling */
.maximized-editor {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  line-height: 1.8;
  padding: 30px;
  margin: 0;
  outline: none;
  resize: none;
  min-height: 400px;
  box-sizing: border-box;
}

/* Hide the main content scrollbar when editor is active */
.maximized-content:has(.maximized-editor) {
  overflow: hidden;
}

/* Fallback for browsers that don't support :has() */
.maximized-content.editing {
  overflow: hidden;
}

.maximized-content .markdown-content h1 {
  font-size: 3em;
  margin-bottom: 30px;
}

.maximized-content .markdown-content h2 {
  font-size: 2.2em;
  margin-bottom: 25px;
}

.maximized-content .markdown-content h3 {
  font-size: 1.8em;
  margin-bottom: 20px;
}

.maximized-content .markdown-content p {
  margin-bottom: 24px;
  font-size: 18px;
}

.maximized-content .markdown-content ul,
.maximized-content .markdown-content ol {
  margin-bottom: 24px;
}

.maximized-content .markdown-content li {
  margin-bottom: 12px;
  font-size: 18px;
}

.maximized-content .markdown-content pre {
  margin-bottom: 24px;
  padding: 24px;
  font-size: 16px;
}

.maximized-content .markdown-content table {
  margin-bottom: 24px;
  font-size: 16px;
}

.maximized-content .markdown-content th,
.maximized-content .markdown-content td {
  padding: 12px 16px;
}

.maximized-content .markdown-content blockquote {
  margin: 24px 0;
  padding: 0 2em;
  font-size: 18px;
}

/* Responsive adjustments for fullscreen */
@media (max-width: 768px) {
  .maximized-node {
    width: 95vw;
    height: 90vh;
  }

  .maximized-header {
    padding: 15px 20px;
  }

  .maximized-content {
    padding: 20px;
    font-size: 16px;
  }

  .maximized-content .markdown-content h1 {
    font-size: 2.2em;
  }

  .maximized-content .markdown-content h2 {
    font-size: 1.8em;
  }

  .maximized-content .markdown-content h3 {
    font-size: 1.4em;
  }

  .maximized-content .markdown-content p {
    font-size: 16px;
  }
}

/* Custom theme support for maximized nodes */
.maximized-node.custom-theme .maximized-title {
  color: var(--accent);
}

.maximized-node.custom-theme .close-maximize-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.maximized-node.custom-theme .maximized-content .markdown-content h1,
.maximized-node.custom-theme .maximized-content .markdown-content h2,
.maximized-node.custom-theme .maximized-content .markdown-content h3,
.maximized-node.custom-theme .maximized-content .markdown-content h4,
.maximized-node.custom-theme .maximized-content .markdown-content h5,
.maximized-node.custom-theme .maximized-content .markdown-content h6 {
  color: var(--text);
}

.maximized-node.custom-theme .maximized-content .markdown-content code {
  color: var(--accent-light);
}

.maximized-node.custom-theme .maximized-content .markdown-content blockquote {
  border-left-color: var(--accent);
}

.maximized-node.custom-theme .maximized-content .markdown-content a {
  color: var(--accent-light);
}

.maximized-node.custom-theme .maximized-content .markdown-content a:hover {
  border-bottom-color: var(--accent-light);
}

.maximized-node.custom-theme .maximized-content .markdown-content ul li::before {
  color: var(--accent);
}

.maximized-node.custom-theme .maximized-content .markdown-content ol li::before {
  color: var(--accent);
}

.maximized-node.custom-theme .maximize-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* Alignment Menu */
.alignment-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  min-width: 280px;
  max-width: 320px;
  padding: 0;
  backdrop-filter: blur(10px);
 
}

.alignment-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.alignment-menu-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.alignment-section {
  padding: 16px 20px;
}

.alignment-section:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.alignment-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.alignment-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.alignment-buttons:last-child {
  margin-bottom: 0;
}

.alignment-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 56px;
}

.alignment-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.alignment-btn svg {
  flex-shrink: 0;
}

.alignment-btn:active {
  transform: translateY(0);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}


.transforming {
  will-change: transform;
}

.transforming * {
  pointer-events: none;
}
/* ============================================
   MOBILE INTERFACE STYLES
   ============================================ */

.mobile-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  z-index: 100;
  padding-top: 70px; /* Account for existing toolbar buttons */
}

.mobile-nodes-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 2rem;
}

.mobile-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  min-height: 60vh;
}

.mobile-empty-state svg {
  margin-bottom: 1.5rem;
  opacity: 0.3;
}

.mobile-empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.mobile-empty-state p {
  font-size: 0.9rem;
  opacity: 0.7;
}

.mobile-node {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s;
}

.mobile-node:active {
  transform: scale(0.98);
}

.mobile-node-header {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  border-left: 3px solid var(--node-accent, var(--accent));
}

.mobile-node-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.mobile-node-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
}

.mobile-node-actions {
  display: flex;
  gap: 0.25rem;
}

.mobile-node-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.mobile-node-btn:active {
  color: var(--accent);
}

.mobile-connections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mobile-connection-tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.mobile-connection-tag.to {
  border-left: 2px solid var(--accent);
}

.mobile-connection-tag.from {
  border-left: 2px solid #0891b2;
}

.mobile-connection-tag:active {
  transform: scale(0.95);
  background: var(--bg-accent-glow);
  border-color: var(--accent);
  color: var(--text);
}

.mobile-node-content {
  padding: 1.5rem;
  line-height: 1.7;
  user-select: text;
  -webkit-user-select: text;
}

.mobile-node-content h1,
.mobile-node-content h2,
.mobile-node-content h3 {
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.mobile-node-content h1 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.mobile-node-content h2 {
  font-size: 1.25rem;
}

.mobile-node-content h3 {
  font-size: 1.1rem;
}

.mobile-node-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.mobile-node-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.mobile-node-content a:hover {
  border-bottom-color: var(--accent);
}

.mobile-node-content code {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
  color: var(--accent-light);
}

.mobile-node-content pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

.mobile-node-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text);
}

.mobile-node-content ul,
.mobile-node-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.mobile-node-content li {
  margin-bottom: 0.5rem;
}

.mobile-node-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.mobile-node-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

.mobile-node-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.mobile-node-content th,
.mobile-node-content td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
}

.mobile-node-content th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.mobile-empty-content {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Help Modal */
.help-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.help-modal.show {
  opacity: 1;
  visibility: visible;
}

.help-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.help-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-width: 500px;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
}

.help-modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.help-modal-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.help-modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
}

.help-section {
  margin-bottom: 30px;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section h4 {
  margin: 0 0 15px 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.help-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.help-item:last-child {
  border-bottom: none;
}

.help-key {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 120px;
  text-align: center;
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.help-description {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* Responsive help modal */
@media (max-width: 768px) {
  .help-modal-content {
    min-width: 90vw;
    max-width: 90vw;
    max-height: 85vh;
  }

  .help-modal-header {
    padding: 16px 20px;
  }

  .help-modal-header h3 {
    font-size: 18px;
  }

  .help-modal-body {
    padding: 20px;
  }

  .help-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .help-key {
    min-width: auto;
    width: 100%;
  }
}

/* Wiki-style [[links]] styling */
.wiki-link {
  color: var(--accent-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  font-weight: 500;
}

.wiki-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.wiki-link-inactive {
  color: var(--text-tertiary);
  font-style: italic;
  text-decoration: none;
  border-bottom: 1px dashed var(--text-tertiary);
}

/* Custom theme wiki link styling */
.node.custom-theme .wiki-link {
  color: var(--node-accent-light);
}

.node.custom-theme .wiki-link:hover {
  color: var(--node-accent);
  border-bottom-color: var(--node-accent);
}

/* Command Palette (VSCode-style search) */
.command-palette {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.command-palette.show {
  opacity: 1;
  visibility: visible;
}

.command-palette-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  overflow: hidden;
}

.command-palette-content {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 600px;
  max-width: 700px;
  max-height: 500px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
}

.command-palette-input {
  width: 100%;
  background: var(--bg-secondary);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 20px 25px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.command-palette-input::placeholder {
  color: var(--text-tertiary);
}

.command-palette-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.command-palette-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.command-palette-item:hover,
.command-palette-item.selected {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.command-palette-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.command-palette-item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.command-palette-item-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.command-palette-item-badge {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.75rem;
}

.command-palette-item-meta {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin-top: 2px;
}

.command-palette-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.4;
  max-height: 9em;
}

.command-palette-item-preview p {
  margin: 0 0 4px;
}

.command-palette-item-preview mark {
  background: var(--accent);
  color: var(--bg-primary, #0b0b0f);
  padding: 0 2px;
  border-radius: 3px;
}

.command-palette-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* Template manager */
.template-manager .help-modal-content {
  max-width: 960px;
}
.template-manager .template-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.template-manager .template-list {
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 8px;
  background: #0f172a;
  max-height: 240px;
  overflow: auto;
}
.template-manager .template-row {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.template-manager .template-row:last-child {
  border-bottom: none;
}
.template-manager .template-row--clickable {
  cursor: pointer;
}
.template-manager .template-row--clickable:hover {
  background: rgba(255,255,255,0.05);
}
.template-manager .template-row small {
  display: block;
  color: #9ca3af;
}
.template-manager .template-row.muted {
  color: #6b7280;
}

.template-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-item-icon {
  font-size: 1.1rem;
}

.template-row-type {
  color: var(--text-tertiary);
  font-size: 0.9rem;
}

.template-row-badge {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
  font-size: 0.75rem;
}

.template-row-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}
.template-manager .template-add-btn,
.command-palette-manage,
.template-editor-actions button {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
}
.template-manager .template-editor {
  margin-top: 12px;
  border-top: 1px solid #1f2937;
  padding-top: 12px;
}
.template-manager .template-editor.hidden {
  display: none;
}
.template-manager .template-input {
  width: 100%;
  padding: 8px;
  background: #0b1224;
  border: 1px solid #1f2937;
  color: #e2e8f0;
  border-radius: 8px;
  margin: 4px 0 10px;
}
.template-manager label {
  display: block;
  font-size: 13px;
  color: #cbd5e1;
}
.template-manager .template-editor-actions {
  display: flex;
  gap: 8px;
}
.template-manager .template-delete-btn {
  border-color: #7f1d1d;
  color: #fecdd3;
}

.command-palette-footer {
  padding: 8px 14px 12px;
  border-top: 1px solid #1f2937;
  display: flex;
  justify-content: flex-end;
}

.saving-indicator {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate3d(-50%, -12px, 0);
  background: rgba(16, 16, 24, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 12px;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 6000;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(8px);
}

.saving-indicator__spinner {
  display: inline-flex;
  gap: 4px;
}

.saving-indicator__spinner span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #f42365);
  opacity: 0.75;
  animation: savingPulse 1s ease-in-out infinite;
}

.saving-indicator__spinner span:nth-child(2) {
  animation-delay: 0.12s;
}

.saving-indicator__spinner span:nth-child(3) {
  animation-delay: 0.24s;
}

.saving-indicator__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.saving-indicator__text strong {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.saving-indicator__text small {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
}

.saving-indicator.visible {
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
}

@keyframes savingPulse {
  0% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-3px); opacity: 1; }
  100% { transform: translateY(0); opacity: 0.6; }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .command-palette-content {
    min-width: 90vw;
    max-width: 90vw;
    top: 80px;
  }

  .command-palette-input {
    padding: 16px 20px;
    font-size: 14px;
  }

  .command-palette-item {
    padding: 10px 14px;
  }
}

/* Minimap */
.minimap-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 180px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 900;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.7;
}

.minimap-container:hover {
  opacity: 1;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}

.minimap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.2) 0%, transparent 100%);
}

.minimap-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  opacity: 0.7;
}

.minimap-zoom-display {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, Consolas, monospace;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.minimap-node-count {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-tertiary);
  opacity: 0.7;
  padding: 0 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  font-family: "SF Mono", Monaco, Consolas, monospace;
}

.minimap-canvas {
  display: block;
  width: 150px;
  height: 150px;
  cursor: crosshair;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin: 0 auto;
}

.minimap-canvas:active {
  cursor: grabbing;
}

.minimap-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.minimap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.minimap-btn:hover {
  background: rgba(244, 35, 101, 0.2);
  color: var(--accent);
  border-color: rgba(244, 35, 101, 0.3);
}

.minimap-btn:active {
  transform: scale(0.95);
}

.minimap-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* Responsive - hide on small screens */
@media (max-width: 768px) {
  .minimap-container {
    display: none;
  }
}

/* Autohide functionality for toolbar and minimap */
.toolbar.autohide,
.minimap-container.autohide {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toolbar.autohide:not(.visible) {
  opacity: 0;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

.toolbar.autohide.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: all;
}

.minimap-container.autohide:not(.visible) {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

.minimap-container.autohide.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Simplified view at minimum zoom (20%) */
.canvas.zoomed-out .node-content {
  /* Hide content at minimum zoom - can't read it anyway */
  display: none !important;
}

.canvas.zoomed-out .node-actions {
  /* Hide interactive elements */
  display: none !important;
}

.canvas.zoomed-out .node-header {
  /* Center the title */
  justify-content: center;
  border-bottom: none !important;
  padding: 16px !important;
  /* Cursor will be dynamically set by JavaScript based on position */
}

.canvas.zoomed-out .node-type {
  /* Show node title bigger in place of content */
  font-size: 3.4rem;
  max-width: 620px;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.canvas.zoomed-out .connection-line {
  /* Make connections much thicker and more visible */
  stroke-width: 6 !important;
  opacity: 0.8 !important;
}

.canvas.zoomed-out .connection-line.active {
  stroke-width: 8 !important;
  opacity: 1 !important;
}

/* Disable transitions when zoomed out for better performance */
.canvas.zoomed-out .node,
.canvas.zoomed-out .node *,
.canvas.zoomed-out .node-btn,
.canvas.zoomed-out .connection-line {
  transition: none !important;
  animation: none !important;
}

/* Inline Editor Toolbar - Compact version in node header */
.inline-editor-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 0 0 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  /* Grid placement: second row, spans both columns */
  grid-column: 1 / -1;
  grid-row: 2;
  justify-content: flex-start;
  flex-wrap: wrap;
  /* Add border-top for visual separation */
  border-top: 1px solid var(--border);
}

.inline-editor-toolbar:hover {
  opacity: 1;
}

.inline-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.inline-toolbar-btn:hover {
  background: var(--node-accent, var(--accent));
  color: var(--text-on-accent);
  border-color: var(--node-accent, var(--accent));
  transform: scale(1.1);
}

.inline-toolbar-btn:active {
  transform: scale(0.95);
}

.inline-toolbar-btn svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

.inline-editor-toolbar .separator {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 2px;
  font-style: normal;
  color: transparent;
  user-select: none;
}

.instruct-block {
  border: 1px solid color-mix(in srgb, var(--node-accent, var(--accent)) 60%, transparent);
  background: color-mix(in srgb, var(--node-accent, var(--accent)) 10%, transparent);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 12px;
}

.instruct-badge {
  grid-column: 1 / -1;
  justify-self: start;
  padding: 4px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-on-accent, #fff);
  background: linear-gradient(135deg, var(--node-accent, var(--accent)), color-mix(in srgb, var(--node-accent, var(--accent)) 65%, #ffffff));
  border-radius: 999px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--node-accent, var(--accent)) 25%, transparent);
}

.instruct-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}

.instruct-body p:last-child {
  margin-bottom: 0;
}

.script-block {
  border: 1px solid color-mix(in srgb, var(--node-accent, var(--accent)) 60%, transparent);
  background: color-mix(in srgb, var(--node-accent, var(--accent)) 7%, transparent);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 12px 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.script-badge {
  justify-self: flex-start;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-on-accent, #fff);
  background: linear-gradient(135deg, var(--node-accent, var(--accent)), color-mix(in srgb, var(--node-accent, var(--accent)) 65%, #ffffff));
  border-radius: 999px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--node-accent, var(--accent)) 25%, transparent);
}

.script-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}

.inline-variable-hints {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  max-height: 250px;
  overflow-y: auto;
  padding: 4px 0;
}

.inline-variable-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-right: 6px;
}

.inline-variable-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.inline-variable-chip:hover {
  border-color: var(--node-accent, var(--accent));
  color: var(--text-on-accent, #fff);
  background: var(--node-accent, var(--accent));
}

/* Ensure toolbar appears when node is being edited */
.node.editing .inline-editor-toolbar {
  opacity: 1;
}

/* Reduce node-type max-width in editing mode to make room for node-actions */
.node.editing .node-type {
  max-width: 300px;
}

/* Custom theme support for inline toolbar */
.node.custom-theme .inline-toolbar-btn:hover {
  background: var(--node-accent);
  border-color: var(--node-accent);
}



.node-type-and-actions-container {
  display: flex;
  align-items: self-start;
  justify-content: space-between;
  gap: 5px;
}

/* Math rendering with KaTeX */
.math-block {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  overflow-x: auto;
  text-align: center;
}

.math-block .katex-display {
  margin: 0;
}

/* Inline math styling */
.katex {
  font-size: 1.1em;
}

/* Make math scrollable on small screens */
.math-block .katex-html {
  overflow-x: auto;
  overflow-y: hidden;
}

/* Math error styling */
.math-error {
  color: var(--accent);
  font-family: monospace;
  background: var(--bg-tertiary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
}

/* ============================================
   EXECUTION SYSTEM STYLES
   ============================================ */

/* Execution state: Running */
.node.executing {
  border-color: #3b82f6;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: executePulse 1.5s ease-in-out infinite;
}

@keyframes executePulse {
  0%, 100% {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 20px 60px rgba(0, 0, 0, 0.8);
  }
  50% {
    border-color: #60a5fa;
    box-shadow: 0 0 30px rgba(96, 165, 250, 0.6), 0 20px 60px rgba(0, 0, 0, 0.8);
  }
}

/* Execution state: Success */
.node.execution-success {
  border-color: #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3), 0 20px 60px rgba(0, 0, 0, 0.8);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Execution state: Error */
.node.execution-error {
  border-color: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4), 0 20px 60px rgba(0, 0, 0, 0.8);
}

/* Execution status badge */
.execution-status-badge {
  position: absolute;
  top: -45px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  pointer-events: auto;
  cursor: pointer;
}

.execution-status-badge svg {
  width: 18px;
  height: 18px;
  display: block;
}

.execution-status-badge.has-result {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-light);
}

.node.showing-result .execution-status-badge.has-result {
  background: rgba(16, 185, 129, 0.12);
  border-color: #10b981;
}

.execution-status-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.4);
}

.node.executing .execution-status-badge {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
  animation: badgeSpin 0.9s linear infinite;
}

.node.execution-success .execution-status-badge {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
}

.node.execution-error .execution-status-badge {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  cursor: help;
  pointer-events: auto;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.5);
  }
}

@keyframes badgeSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Error tooltip on hover */
.node.execution-error .execution-status-badge:hover::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  margin-top: 0;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid #ef4444;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  max-width: 300px;
  text-overflow: ellipsis;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Execution controls in toolbar */
.execution-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 12px;
  border-left: 1px solid var(--border);
}

.execution-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid #3b82f6;
  border-radius: 8px;
  color: #3b82f6;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.execution-btn:hover {
  background: #3b82f6;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.execution-btn:active {
  transform: translateY(0);
}

.execution-btn.stop {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.execution-btn.stop:hover {
  background: #ef4444;
  color: white;
}

.execution-btn svg {
  width: 14px;
  height: 14px;
}

/* LLM Config button */
.llm-config-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid #a855f7;
  border-radius: 8px;
  color: #a855f7;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.llm-config-btn:hover {
  background: #a855f7;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.llm-config-btn svg {
  width: 14px;
  height: 14px;
}

/* Iteration count badge for cycling nodes */
.execution-status-badge[data-iterations]::before {
  content: attr(data-iterations);
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-secondary);
}

/* HTML preview node */
.html-preview-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.html-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.html-preview-label {
  font-weight: 600;
}

.html-preview-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.html-preview-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.html-preview-frame {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  min-height: 200px;
}

.html-preview-iframe {
  width: 100%;
  height: 260px;
  border: 0;
  background: #0b0c10;
}

.html-preview-note,
.html-preview-helper {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.html-preview-empty {
  color: #a6accd;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  text-align: center;
  padding: 32px;
}

.html-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.html-preview-panel {
  width: min(1100px, 95vw);
  height: min(90vh, 900px);
  background: #0f1116;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 16px;
}

.html-preview-overlay-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.html-preview-iframe.fullscreen {
  flex: 1;
  height: auto;
  border-radius: 10px;
}
