:root {
  --bg-0: #1f232a;
  --bg-1: rgba(34, 39, 46, 0.94);
  --bg-2: rgba(50, 57, 67, 0.82);
  --ink-0: #eef2f7;
  --ink-1: #cad3de;
  --ink-2: #8c97a5;
  --line-0: rgba(124, 136, 151, 0.14);
  --accent: #7f8ea3;
  --accent-strong: #a9b8ca;
  --accent-soft: rgba(127, 142, 163, 0.18);
  --teal: #aeb9c7;
  --teal-soft: rgba(120, 132, 148, 0.22);
  --danger: #d7a4a4;
  --danger-soft: rgba(124, 78, 78, 0.26);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
  --shadow-md: 0 18px 40px rgba(0, 0, 0, 0.34);
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.24);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --menu-width: min(248px, calc(100vw - 18px));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink-0);
  background:
    radial-gradient(circle at 16% 18%, rgba(103, 115, 130, 0.1), transparent 24%),
    radial-gradient(circle at 78% 18%, rgba(85, 94, 109, 0.08), transparent 28%),
    radial-gradient(circle at 50% 80%, rgba(121, 132, 148, 0.08), transparent 30%),
    linear-gradient(180deg, #20242b 0%, #1c2027 52%, #181c22 100%);
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none !important;
  box-shadow: none !important;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 420px));
  justify-content: center;
  align-content: center;
  gap: 18px;
  padding: 28px;
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid rgba(102, 113, 128, 0.18);
  border-radius: 24px;
  background: rgba(28, 33, 40, 0.94);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}

.auth-card-wide {
  max-width: 560px;
}

.auth-copy {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.55;
}

.auth-alert {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(124, 78, 78, 0.22);
  color: #f4c9c9;
  border: 1px solid rgba(215, 164, 164, 0.24);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--ink-1);
  font-size: 0.88rem;
}

.auth-form input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(103, 114, 128, 0.22);
  background: rgba(39, 45, 53, 0.92);
  color: var(--ink-0);
}

.auth-form input:focus {
  outline: 2px solid rgba(124, 141, 163, 0.26);
  border-color: rgba(149, 165, 187, 0.44);
}

.auth-submit {
  text-align: center;
}

.session-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.save-meta-bar {
  position: relative;
  z-index: 1;
  max-width: 100%;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  width: auto;
}

.save-meta-text {
  display: block;
  max-width: 100%;
  color: var(--ink-2);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.92;
  text-align: right;
  white-space: nowrap;
}

.session-button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.84rem;
  line-height: 1;
}

.session-button-label {
  color: var(--ink-2);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.session-button strong {
  display: inline-block;
  max-width: 168px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

#save-brain-button {
  min-width: 0;
}

#brain-manager-button strong {
  max-width: 150px;
}

#user-menu-button strong {
  max-width: 190px;
}

.logout-form {
  display: grid;
}

.brain-switch-card {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 13px;
  text-align: left;
  background: rgba(47, 54, 63, 0.88);
  color: var(--ink-1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.brain-switch-card strong {
  color: var(--ink-0);
}

.brain-switch-card span {
  color: var(--ink-2);
  font-size: 0.68rem;
}

.brain-switch-head,
.brain-switch-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brain-switch-head {
  align-items: flex-start;
}

.brain-switch-head strong {
  flex: 1;
}

.brain-switch-foot {
  flex-wrap: wrap;
}

.brain-title-button,
.brain-title-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-0);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}

.brain-title-button {
  cursor: text;
}

.brain-title-button:hover {
  color: #f5f8fc;
  opacity: 0.96;
}

.brain-title-input {
  padding: 2px 0;
  border-bottom: 1px solid rgba(169, 184, 202, 0.45);
  border-radius: 0;
  outline: none;
  box-shadow: none;
}

.brain-open-button {
  width: auto;
  text-align: center;
}

.brain-open-button {
  flex-shrink: 0;
}

.brain-delete-button {
  width: auto;
  flex-shrink: 0;
}

.brain-switch-card.active {
  background: rgba(91, 102, 117, 0.42);
  border: 1px solid rgba(169, 184, 202, 0.18);
}

.workspace-shell,
.canvas-panel {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

.canvas-viewport {
  position: relative;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.grid-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(98, 107, 121, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 107, 121, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.035), transparent 18%),
    radial-gradient(circle at 76% 22%, rgba(126, 138, 155, 0.05), transparent 24%),
    linear-gradient(180deg, rgba(33, 38, 46, 0.96), rgba(27, 31, 38, 0.96));
  background-size: 32px 32px, 32px 32px, auto, auto, auto;
}

.canvas-stage {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.context-layer,
.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.context-layer {
  pointer-events: none;
  overflow: visible;
  opacity: 0.4;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.85) 48%, rgba(0, 0, 0, 0.28) 78%, transparent 100%);
}

.edge-layer {
  overflow: visible;
  pointer-events: auto;
}

.node-layer {
  pointer-events: none;
}

.menu-toggle-button,
.menu-close-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.tab-button,
.tab-close {
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

.menu-toggle-button:hover,
.menu-close-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tab-button:hover,
.tab-close:hover {
  transform: translateY(-1px);
}

.menu-toggle-button {
  position: relative;
  z-index: 2;
  width: 50px;
  height: 50px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 0 13px;
  border-radius: 18px;
  background: rgba(42, 48, 57, 0.9);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.menu-toggle-button span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #eef2f7;
  transform-origin: center;
}

.menu-toggle-button.is-open span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.menu-toggle-button.is-open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle-button.is-open span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

.app-shell.menu-open .menu-toggle-button {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.top-layout {
  position: fixed;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 88;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 520px) minmax(420px, 520px);
  grid-template-areas: "left center right";
  align-items: start;
  gap: 8px 14px;
  pointer-events: none;
}

.top-layout-left,
.top-layout-right {
  min-width: 0;
  display: grid;
  align-items: start;
  gap: 8px;
  pointer-events: auto;
}

.top-layout-left {
  grid-area: left;
  grid-template-columns: 50px minmax(0, 1fr);
}

.top-layout-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-self: end;
  max-width: 100%;
  width: fit-content;
}

.neuron-tabbar-shell {
  position: relative;
  z-index: 65;
  pointer-events: none;
  min-width: 0;
}

.top-search-shell {
  grid-area: center;
  position: relative;
  z-index: 66;
  width: 100%;
  max-width: 520px;
  justify-self: center;
  pointer-events: auto;
}

#brain-manager-button strong {
  max-width: 132px;
}

#user-menu-button strong {
  max-width: 168px;
}

.top-search-field {
  display: block;
  pointer-events: auto;
}

.top-search-field input {
  text-align: center;
  background: rgba(26, 31, 38, 0.9);
  border-color: rgba(112, 126, 144, 0.24);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.multi-select-button {
  min-width: 0;
  width: auto;
  padding: 6px 12px;
  justify-content: center;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(228, 235, 244, 0.88);
  background: rgba(27, 32, 39, 0.82);
  border: 1px solid rgba(112, 126, 144, 0.18);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.multi-select-button.is-active {
  color: #eff5fc;
  background: linear-gradient(160deg, rgba(92, 105, 123, 0.96) 0%, rgba(67, 77, 91, 0.96) 100%);
  border-color: rgba(171, 188, 212, 0.24);
}

.top-search-field input::placeholder {
  color: rgba(204, 214, 226, 0.58);
}

.mobile-view-switch {
  position: fixed;
  top: 84px;
  left: 50%;
  z-index: 68;
  display: none !important;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(27, 32, 39, 0.92);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
  transform: translateX(-50%);
}

.mobile-view-button {
  min-width: 78px;
  padding: 8px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 700;
}

.mobile-view-button.active {
  background: rgba(86, 98, 113, 0.44);
  color: var(--ink-0);
}

.mobile-explorer {
  position: absolute;
  inset: 0;
  z-index: 34;
  display: none;
  overflow: auto;
  padding: 120px 10px 18px;
  background:
    linear-gradient(180deg, rgba(19, 23, 29, 0.98), rgba(16, 20, 26, 0.98));
}

.mobile-explorer-shell {
  display: grid;
  gap: 8px;
}

.mobile-explorer-header,
.mobile-explorer-summary,
.mobile-explorer-section,
.mobile-explorer-actions {
  border-radius: 14px;
  border: 1px solid rgba(96, 109, 126, 0.12);
  background: rgba(28, 33, 40, 0.92);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.mobile-explorer-header,
.mobile-explorer-summary,
.mobile-explorer-section {
  padding: 10px 11px;
}

.mobile-explorer-path {
  display: flex;
  gap: 6px;
  color: var(--ink-2);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mobile-explorer-header h3 {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.1;
}

.mobile-explorer-ref {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 0.72rem;
}

.mobile-explorer-summary p {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.78rem;
  line-height: 1.4;
}

.mobile-explorer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
}

.mobile-explorer-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.mobile-explorer-folder-icon {
  color: #d5dfeb;
  font-size: 0.7rem;
  line-height: 1;
}

.mobile-explorer-list {
  display: grid;
  gap: 4px;
}

.mobile-explorer-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 10px;
  background: rgba(40, 46, 55, 0.82);
  text-align: left;
  color: var(--ink-1);
}

.mobile-explorer-item-icon {
  color: #dce5ef;
  font-size: 0.74rem;
}

.mobile-explorer-item-main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.mobile-explorer-item strong {
  color: var(--ink-0);
  font-size: 0.8rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-explorer-item-main span,
.mobile-explorer-empty {
  color: var(--ink-2);
  font-size: 0.66rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-explorer-item small {
  color: #dfe6ee;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-explorer-empty {
  margin: 0;
  padding: 4px 0 2px;
  font-size: 0.68rem;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
}

.menu-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.control-menu {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 80;
  width: var(--menu-width);
  padding: 10px 0 10px 10px;
  transform: translateX(calc(-100% - 24px));
  pointer-events: none;
}

.control-menu.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.session-menu {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 80;
  width: min(272px, calc(100vw - 18px));
  padding: 88px 10px 10px 0;
  transform: translateX(calc(100% + 24px));
  pointer-events: none;
}

.session-menu.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.session-panel {
  grid-template-rows: auto auto 1fr;
}

.menu-panel {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(102, 113, 128, 0.18);
  border-radius: 18px;
  background: rgba(28, 33, 40, 0.94);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
  overflow-y: auto;
  overflow-x: hidden;
}

.menu-header,
.brand-block,
.panel-head,
.inline-node-actions,
.status-cluster {
  display: flex;
  align-items: center;
}

.menu-header {
  justify-content: space-between;
  gap: 8px;
}

.brand-block {
  gap: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(160deg, #636d7c 0%, #434b57 100%);
  color: #f0f4f8;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.brand-block h1,
.panel-head h2 {
  margin: 0;
  font-size: 0.75rem;
}

.menu-close-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(55, 62, 72, 0.92);
  color: var(--ink-1);
  box-shadow: var(--shadow-sm);
}

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

.search-field {
  position: relative;
  display: grid;
  gap: 6px;
}

.search-field span {
  color: var(--ink-1);
  font-size: 0.68rem;
}

.search-field input,
.inline-node-title,
.inline-node-textarea,
.inline-node-title-display {
  width: 100%;
  border: 1px solid rgba(103, 114, 128, 0.22);
  background: rgba(39, 45, 53, 0.92);
  color: var(--ink-0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.search-field input {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
}

.search-field input:focus,
.inline-node-title:focus,
.inline-node-textarea:focus {
  outline: 2px solid rgba(124, 141, 163, 0.26);
  border-color: rgba(149, 165, 187, 0.44);
}

.button-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  width: 100%;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 12px;
  text-align: left;
  font-size: 0.76rem;
}

.primary-button {
  background: linear-gradient(160deg, #596474 0%, #434b58 100%);
  color: #f2f6fb;
  box-shadow: var(--shadow-sm);
}

.secondary-button {
  background: rgba(66, 74, 85, 0.86);
  color: #d6dfe9;
}

.ghost-button {
  background: rgba(48, 55, 64, 0.9);
  color: var(--ink-1);
}

.primary-button.small,
.secondary-button.small,
.ghost-button.small,
.danger-button.small {
  width: auto;
  min-height: 0;
  padding: 6px 9px;
  text-align: center;
  font-size: 0.72rem;
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-cluster {
  flex-wrap: wrap;
  gap: 6px;
}

.menu-status-cluster {
  justify-content: flex-start;
}

.mode-chip,
.stats-chip,
.summary-pill,
.tab-pill {
  background: rgba(47, 54, 63, 0.88);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.mode-chip,
.stats-chip {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--ink-1);
  font-size: 0.7rem;
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  padding: 1px 2px 4px;
  pointer-events: auto;
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar {
  display: none;
}

.tab-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 3px;
  padding: 2px;
  border-radius: 10px;
  max-width: min(126px, calc(100vw - 98px));
}

.tab-pill.active {
  background: rgba(91, 102, 117, 0.42);
}

.tab-button {
  flex: 1;
  min-width: 0;
  padding: 4px 7px;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  color: var(--ink-1);
  font-size: 0.76rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-pill.active .tab-button {
  color: var(--accent-strong);
  font-weight: 700;
}

.tab-close {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(60, 68, 79, 0.92);
  color: var(--ink-2);
  font-size: 0.6rem;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
}

.summary-stack {
  display: grid;
  gap: 10px;
}

.summary-pill {
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--ink-1);
}

.node-card {
  --bubble-start: #707887;
  --bubble-end: #4d5563;
  --bubble-glow: rgba(77, 85, 99, 0.28);
  --bubble-radius: 50%;
  --bubble-tilt: 0deg;
  --bubble-nucleus-x: 52%;
  --bubble-nucleus-y: 46%;
  --bubble-pulse: 7.2s;
  --bubble-saturate: 1;
  --bubble-brightness: 1;
  --bubble-opacity: 1;
  --bubble-label-opacity: 1;
  position: absolute;
  display: block;
  z-index: 2;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  user-select: none;
  touch-action: none;
  -webkit-user-drag: none;
  cursor: grab;
  transform-origin: center center;
  transition: transform 180ms ease, filter 180ms ease, z-index 180ms ease;
  pointer-events: auto;
}

.context-node {
  --bubble-start: #707887;
  --bubble-end: #4d5563;
  --bubble-glow: rgba(77, 85, 99, 0.28);
  --bubble-saturate: 0.86;
  --bubble-brightness: 0.92;
  --bubble-opacity: 0.78;
  --bubble-label-opacity: 0.44;
  position: absolute;
  filter: blur(3px) saturate(0.9);
  transform: scale(0.985);
  opacity: 0.78;
}

.context-node h3 {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  margin: 0;
  width: max-content;
  max-width: 130px;
  color: rgba(220, 229, 239, 0.34);
  opacity: var(--bubble-label-opacity);
  font-size: 0.7rem;
  line-height: 1.12;
  text-align: center;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.node-card::before {
  display: none;
}

.node-card:hover {
  z-index: 12;
  transform: translateY(-3px) scale(1.72);
  filter: brightness(1.16) saturate(1.7);
}

.node-card.selected {
  z-index: 14;
  transform: translateY(-1px);
}

.node-card.multi-selected {
  z-index: 14;
  box-shadow: 0 0 0 2px rgba(193, 210, 236, 0.58), 0 14px 26px rgba(0, 0, 0, 0.24);
}

.node-card.preview-focus {
  z-index: 15;
  transform: translateY(-2px) scale(1.08);
}

.node-card.preview-related {
  z-index: 13;
  transform: translateY(-1px) scale(1.03);
}

.node-card.connect-source {
  z-index: 16;
}

.node-card.editing {
  cursor: default;
  user-select: text;
  pointer-events: none;
}

.node-card h3 {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  margin: 0;
  width: max-content;
  max-width: 110px;
  color: #edf2f8;
  opacity: var(--bubble-label-opacity);
  font-size: 0.7rem;
  line-height: 1.12;
  text-wrap: balance;
  text-align: center;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

body.canvas-performance-hide-labels .node-card h3,
body.canvas-performance-hide-labels .context-node h3 {
  display: none;
}

.node-bubble-dot {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: var(--bubble-radius);
  border: 1px solid rgba(210, 225, 241, 0.12);
  background:
    radial-gradient(circle at 24% 22%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06) 20%, transparent 30%),
    radial-gradient(circle at var(--bubble-nucleus-x) var(--bubble-nucleus-y), rgba(246, 250, 255, 0.22), rgba(220, 230, 242, 0.1) 12%, rgba(103, 120, 146, 0.22) 18%, transparent 32%),
    radial-gradient(circle at 68% 72%, rgba(255, 255, 255, 0.06), transparent 26%),
    linear-gradient(155deg, var(--bubble-start) 0%, var(--bubble-end) 100%);
  opacity: 1;
  filter: saturate(var(--bubble-saturate)) brightness(var(--bubble-brightness));
  transform: rotate(var(--bubble-tilt));
  box-shadow:
    0 10px 24px var(--bubble-glow),
    0 0 18px rgba(232, 240, 248, 0.06),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: neuronPulse var(--bubble-pulse) ease-in-out infinite;
  overflow: hidden;
}

body.canvas-performance-simplified .node-bubble-dot {
  background:
    radial-gradient(circle at 34% 32%, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(155deg, var(--bubble-start) 0%, var(--bubble-end) 100%);
  filter: none;
  box-shadow:
    0 6px 14px var(--bubble-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  animation: none;
}

.context-node .node-bubble-dot {
  opacity: var(--bubble-opacity);
  inset: 0;
}

.node-bubble-dot::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: var(--bubble-radius);
  background:
    radial-gradient(circle at 22% 26%, rgba(255, 255, 255, 0.08), transparent 18%),
    radial-gradient(circle at 74% 66%, rgba(255, 255, 255, 0.05), transparent 22%);
  border: 1px solid rgba(255, 255, 255, 0.04);
  mix-blend-mode: screen;
}

.node-bubble-dot::after {
  content: "";
  position: absolute;
  left: calc(var(--bubble-nucleus-x) - 16%);
  top: calc(var(--bubble-nucleus-y) - 16%);
  width: 32%;
  height: 32%;
  border-radius: 48% 52% 44% 56% / 50% 46% 54% 50%;
  background:
    radial-gradient(circle at 34% 32%, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.12) 18%, rgba(115, 132, 159, 0.46) 54%, rgba(56, 67, 84, 0.22) 100%);
  box-shadow:
    0 0 18px rgba(226, 236, 248, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 0.84;
}

body.canvas-performance-simplified .node-bubble-dot::before,
body.canvas-performance-simplified .node-bubble-dot::after {
  display: none;
}

.node-card.selected .node-bubble-dot {
  border-color: rgba(213, 224, 237, 0.34);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.34),
    0 0 0 4px rgba(126, 138, 155, 0.12),
    0 0 24px rgba(191, 208, 224, 0.14);
}

.node-card.preview-focus .node-bubble-dot {
  border-color: rgba(223, 233, 244, 0.52);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.36),
    0 0 0 4px rgba(164, 181, 201, 0.18),
    0 0 34px rgba(188, 203, 221, 0.24);
}

.node-card.preview-related .node-bubble-dot {
  border-color: rgba(205, 217, 231, 0.24);
  box-shadow:
    0 9px 20px rgba(0, 0, 0, 0.28),
    0 0 0 2px rgba(134, 149, 167, 0.08);
}

.node-card.tab-root .node-bubble-dot {
  border-color: rgba(227, 235, 244, 0.36);
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.34),
    0 0 0 4px rgba(173, 187, 205, 0.12);
}

body.canvas-performance-simplified .node-card.selected .node-bubble-dot,
body.canvas-performance-simplified .node-card.preview-focus .node-bubble-dot,
body.canvas-performance-simplified .node-card.preview-related .node-bubble-dot,
body.canvas-performance-simplified .node-card.tab-root .node-bubble-dot {
  box-shadow:
    0 6px 14px var(--bubble-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.node-quick-add {
  position: absolute;
  z-index: 6;
  width: var(--quick-add-size, 20px);
  height: var(--quick-add-size, 20px);
  display: block;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: transparent;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.76);
  transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.node-quick-add::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68%;
  height: 2px;
  border-radius: 999px;
  background: rgba(241, 247, 253, 0.96);
  box-shadow:
    0 0 10px rgba(228, 237, 247, 0.44),
    0 1px 2px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.node-quick-add::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 68%;
  border-radius: 999px;
  background: rgba(241, 247, 253, 0.96);
  box-shadow:
    0 0 10px rgba(228, 237, 247, 0.44),
    0 1px 2px rgba(0, 0, 0, 0.38);
  transform: translate(-50%, -50%);
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.node-quick-add:hover {
  filter: brightness(1.08);
}

.node-quick-add:hover::before,
.node-quick-add:hover::after {
  background: rgba(250, 252, 255, 1);
  box-shadow:
    0 0 14px rgba(232, 239, 246, 0.62),
    0 2px 4px rgba(0, 0, 0, 0.34);
}

.node-quick-add.edge-visible,
.node-card.connect-source .node-quick-add {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.floating-panel {
  position: absolute;
  z-index: 40;
  border-radius: 18px;
  border: 1px solid rgba(96, 108, 123, 0.18);
  background: rgba(33, 38, 46, 0.96);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
}

.editor-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: auto;
}

.document-sheet-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: auto;
  overscroll-behavior: contain;
}

.document-sheet-backdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 12, 16, 0.34);
  backdrop-filter: blur(6px);
  overscroll-behavior: contain;
}

.document-sheet-card {
  width: min(1240px, calc(100vw - 36px));
  height: min(88vh, 980px);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 20px;
  border-radius: 28px;
  border: 1px solid rgba(109, 122, 140, 0.22);
  background: linear-gradient(180deg, rgba(31, 36, 43, 0.98), rgba(19, 23, 29, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  overscroll-behavior: contain;
}

.document-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.document-sheet-header h2 {
  margin: 4px 0 0;
  font-size: clamp(1.28rem, 1.9vw, 1.8rem);
}

.document-sheet-meta {
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 0.82rem;
}

.document-sheet-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.document-sheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid rgba(94, 107, 123, 0.2);
  background: rgba(40, 46, 55, 0.72);
}

.document-sheet-tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(26, 31, 38, 0.28);
  border: 1px solid rgba(122, 136, 154, 0.08);
}

.document-sheet-tool {
  min-width: 30px;
  font-weight: 700;
  min-height: 28px;
  padding: 4px 7px;
  font-size: 0.72rem;
  line-height: 1;
  border-radius: 9px;
}

.document-sheet-tool-color {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  gap: 4px;
  overflow: hidden;
}

.document-sheet-tool-color span {
  position: relative;
  z-index: 1;
}

.document-sheet-text-color {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid rgba(122, 136, 154, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.document-sheet-text-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.document-sheet-text-color::-webkit-color-swatch {
  border: 0;
  border-radius: 999px;
}

.document-sheet-editor-shell {
  position: relative;
  min-height: 0;
  height: 100%;
}

.document-sheet-editor {
  overflow: auto;
  min-height: 0;
  height: 100%;
  padding: 28px 32px;
  border-radius: 22px;
  border: 1px solid rgba(104, 116, 132, 0.22);
  background: rgba(245, 240, 231, 0.96);
  color: #241d18;
  font-size: 1rem;
  line-height: 1.72;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-sheet-editor.is-drop-target {
  outline: 2px dashed rgba(46, 90, 147, 0.42);
  outline-offset: -10px;
}

.document-sheet-editor::after {
  content: "";
  display: block;
  clear: both;
}

.document-sheet-editor:focus {
  outline: 2px solid rgba(95, 122, 157, 0.38);
  outline-offset: 0;
}

.document-sheet-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(68, 59, 54, 0.48);
}

.document-sheet-editor h1,
.document-sheet-editor h2,
.document-sheet-editor h3,
.document-sheet-editor h4 {
  margin: 0 0 14px;
  line-height: 1.2;
  color: #17120e;
}

.document-sheet-editor p,
.document-sheet-editor ul,
.document-sheet-editor ol,
.document-sheet-editor blockquote,
.document-sheet-editor pre,
.document-sheet-editor hr {
  margin: 0 0 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-sheet-editor ul,
.document-sheet-editor ol {
  padding-left: 24px;
}

.document-sheet-editor blockquote {
  margin-left: 0;
  padding-left: 14px;
  border-left: 3px solid rgba(93, 101, 116, 0.4);
  color: #4a4037;
}

.document-sheet-editor pre,
.document-sheet-editor code {
  font-family: Consolas, "Courier New", monospace;
}

.document-sheet-editor pre {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(37, 33, 29, 0.92);
  color: #f6efe4;
  overflow: auto;
  white-space: pre-wrap;
}

.document-sheet-editor code {
  padding: 0.14em 0.38em;
  border-radius: 8px;
  background: rgba(57, 50, 43, 0.12);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.document-sheet-editor span[data-text-color] {
  color: var(--text-color, inherit);
}

.document-sheet-editor mark {
  padding: 0.06em 0.2em;
  border-radius: 6px;
  background: rgba(224, 198, 119, 0.42);
  color: inherit;
}

.document-sheet-editor sup,
.document-sheet-editor sub {
  font-size: 0.72em;
}

.document-sheet-editor hr {
  border: 0;
  border-top: 1px solid rgba(86, 76, 68, 0.26);
}

.document-sheet-editor a:not(.document-reference-link) {
  color: #2e5a93;
  text-decoration: underline;
  text-decoration-color: rgba(46, 90, 147, 0.34);
}

.document-sheet-editor img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 18px auto;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(36, 29, 24, 0.14);
  cursor: grab;
  transition: box-shadow 160ms ease, transform 160ms ease, outline-color 160ms ease;
}

.document-sheet-editor img[data-image-wrap="left"] {
  float: left;
  display: inline-block;
  max-width: min(52%, 420px);
  margin: 8px 20px 14px 0;
}

.document-sheet-editor img[data-image-wrap="right"] {
  float: right;
  display: inline-block;
  max-width: min(52%, 420px);
  margin: 8px 0 14px 20px;
}

.document-sheet-editor img.is-selected {
  outline: 3px solid rgba(46, 90, 147, 0.45);
  outline-offset: 4px;
  box-shadow: 0 18px 38px rgba(36, 29, 24, 0.18);
  transform: translateY(-1px);
}

.document-sheet-editor img:active {
  cursor: grabbing;
}

.document-sheet-editor img.is-dragging {
  opacity: 0.88;
  box-shadow: 0 24px 44px rgba(36, 29, 24, 0.22);
}

.document-sheet-editor table {
  display: table;
  width: 100%;
  margin: 0 0 18px;
  border-collapse: collapse;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(36, 29, 24, 0.08);
}

.document-sheet-editor th,
.document-sheet-editor td {
  min-width: 96px;
  padding: 10px 12px;
  border: 1px solid rgba(104, 92, 80, 0.14);
  vertical-align: top;
  text-align: left;
}

.document-sheet-editor th {
  background: rgba(53, 67, 87, 0.1);
  color: #233244;
  font-weight: 700;
}

.document-sheet-editor table.is-selected {
  outline: 3px solid rgba(46, 90, 147, 0.38);
  outline-offset: 4px;
}

.document-sheet-editor [data-timeline] {
  position: relative;
  display: grid;
  gap: 20px;
  margin: 18px 0 24px;
  padding: 8px 0;
}

.document-sheet-editor [data-timeline]::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(126, 93, 87, 0.18), rgba(126, 93, 87, 0.5), rgba(126, 93, 87, 0.18));
}

.document-sheet-editor [data-timeline-item] {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.document-sheet-editor [data-timeline-card] {
  min-height: 96px;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 32px rgba(63, 45, 33, 0.1);
  color: #3a2f2a;
}

.document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card] {
  grid-column: 1;
}

.document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card] {
  grid-column: 3;
}

.document-sheet-editor [data-timeline-card] p:last-child {
  margin-bottom: 0;
}

.document-sheet-editor [data-timeline-marker] {
  grid-column: 2;
  position: relative;
  z-index: 1;
  width: 74px;
  display: grid;
  place-items: center;
}

.document-sheet-editor [data-timeline-marker] p {
  margin: 0;
  min-width: 54px;
  padding: 8px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c4f4e, #9d6660);
  color: #fffaf3;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  box-shadow: 0 10px 24px rgba(124, 79, 78, 0.26);
}

.document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card]::after,
.document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card]::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-50%) rotate(45deg);
}

.document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card],
.document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card] {
  position: relative;
}

.document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card]::after {
  right: -9px;
}

.document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card]::before {
  left: -9px;
}

.document-sheet-editor [data-timeline-card] img {
  margin-top: 14px;
}

.document-sheet-editor [data-drawing-block] {
  width: min(320px, 100%);
  aspect-ratio: 1 / 1;
  margin: 18px auto;
  position: relative;
  border-radius: 20px;
  border: 1px solid rgba(104, 92, 80, 0.18);
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(36, 29, 24, 0.08);
  overflow: hidden;
  cursor: default;
}

.document-sheet-editor [data-drawing-move-handle] {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(88, 66, 48, 0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(122, 95, 70, 0.96), rgba(88, 66, 48, 0.96));
  box-shadow: 0 8px 18px rgba(36, 29, 24, 0.16);
  cursor: grab;
  color: transparent;
  font-size: 0;
  pointer-events: auto !important;
  appearance: none;
  transform: translate(0, 0);
}

.document-sheet-editor [data-drawing-move-handle]:active {
  cursor: grabbing;
}

.document-sheet-editor [data-drawing-block][data-drawing-wrap="left"] {
  float: left;
  display: inline-block;
  width: min(52%, 420px);
  max-width: min(52%, 420px);
  margin: 8px 20px 14px 0;
}

.document-sheet-editor [data-drawing-block][data-drawing-wrap="right"] {
  float: right;
  display: inline-block;
  width: min(52%, 420px);
  max-width: min(52%, 420px);
  margin: 8px 0 14px 20px;
}

.document-sheet-editor [data-drawing-block].is-selected {
  outline: 3px solid rgba(46, 90, 147, 0.38);
  outline-offset: 4px;
}

.document-sheet-editor [data-drawing-canvas] {
  width: 100%;
  height: 100%;
  display: block;
  background: #ffffff;
  touch-action: none;
  cursor: crosshair;
}

.document-sheet-editor [data-timeline] + p,
.document-sheet-editor [data-drawing-block] + p {
  min-height: 1.3em;
}

@media (max-width: 860px) {
  .document-sheet-editor [data-timeline]::before {
    left: 28px;
    transform: none;
  }

  .document-sheet-editor [data-timeline-item] {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .document-sheet-editor [data-timeline-marker] {
    grid-column: 1;
    width: 56px;
    padding-top: 10px;
  }

  .document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card],
  .document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card] {
    grid-column: 2;
  }

  .document-sheet-editor [data-timeline-item][data-side="left"] [data-timeline-card]::after,
  .document-sheet-editor [data-timeline-item][data-side="right"] [data-timeline-card]::before {
    top: 26px;
    left: -9px;
    right: auto;
    transform: rotate(45deg);
  }
}

.document-sheet-editor td:empty::before,
.document-sheet-editor th:empty::before {
  content: "\00a0";
}

.document-sheet-resize-handle {
  position: absolute;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(40, 52, 68, 0.24);
  border-radius: 999px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.96) 0 32%, transparent 34%),
    linear-gradient(135deg, rgba(46, 90, 147, 0.96), rgba(31, 56, 88, 0.96));
  box-shadow: 0 10px 22px rgba(21, 29, 41, 0.2);
  cursor: nwse-resize;
  transform: translate(-50%, -50%);
}

.document-sheet-resize-handle.hidden {
  display: none;
}

.document-sheet-editor .document-reference-link {
  color: #375f96;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed rgba(55, 95, 150, 0.38);
  cursor: pointer;
}

.document-sheet-editor .document-reference-link:hover {
  color: #274a7b;
  border-bottom-color: rgba(39, 74, 123, 0.58);
}

.document-sheet-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px 10px;
}

.document-sheet-hint {
  color: var(--ink-2);
  font-size: 0.72rem;
  line-height: 1.35;
}

.editor-card {
  position: absolute;
  width: min(360px, calc(100vw - 32px));
  min-height: 260px;
  padding: 18px;
  border-radius: 28px;
  border: 1px solid rgba(98, 110, 126, 0.22);
  background: linear-gradient(180deg, rgba(34, 39, 46, 0.98), rgba(26, 31, 38, 0.98));
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
  pointer-events: auto;
  touch-action: manipulation;
}

.editor-card.preview-size-small {
  width: min(318px, calc(100vw - 32px));
  min-height: 220px;
  padding: 14px;
  border-radius: 24px;
}

.editor-card.preview-size-large {
  width: min(436px, calc(100vw - 32px));
  min-height: 320px;
  padding: 20px;
  border-radius: 30px;
}

.editor-card .node-ref-chip {
  margin-bottom: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
  background: rgba(91, 103, 118, 0.26);
  color: #edf3fa;
}

.inline-node-editor {
  position: relative;
  z-index: 8;
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  user-select: text;
  pointer-events: auto;
}

.editor-card.preview-size-small .inline-node-editor {
  gap: 8px;
}

.editor-card.preview-size-large .inline-node-editor {
  gap: 12px;
}

.inline-node-title,
.inline-node-title-display,
.inline-node-summary-card {
  border-radius: 16px;
  user-select: text;
  pointer-events: auto;
  touch-action: manipulation;
}

.inline-node-title {
  padding: 8px 10px;
  font-size: 0.92rem;
  font-weight: 700;
}

.inline-node-title-display {
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 700;
}

.inline-node-summary-card {
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(100, 111, 126, 0.2);
  background: rgba(44, 50, 59, 0.92);
  color: var(--ink-1);
  text-align: left;
  cursor: pointer;
}

.inline-node-summary-card:hover {
  border-color: rgba(131, 144, 163, 0.34);
  background: rgba(49, 56, 66, 0.96);
}

.inline-node-summary-label {
  color: var(--ink-2);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inline-node-summary-text {
  color: #eef4fb;
  font-size: 0.8rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.inline-node-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  gap: 10px;
}

.inline-node-hint {
  flex: 1 1 0;
  min-width: 0;
}

.inline-node-actions-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: 0 0 auto;
  gap: 8px;
}

.inline-node-control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.inline-node-button-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.inline-neuron-button-compact,
.inline-delete-button {
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.72rem;
}

.inline-node-color-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inline-node-size-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.inline-node-size-select {
  min-width: 98px;
  padding: 5px 9px;
  border: 1px solid rgba(122, 135, 152, 0.34);
  border-radius: 999px;
  background: rgba(39, 45, 53, 0.92);
  color: var(--ink-1);
  font-size: 0.74rem;
}

.inline-node-size-select:focus {
  outline: 2px solid rgba(124, 141, 163, 0.26);
  border-color: rgba(149, 165, 187, 0.44);
}

.inline-node-color {
  width: 36px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(122, 135, 152, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.inline-node-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.inline-node-color::-webkit-color-swatch {
  border: 0;
  border-radius: 999px;
}

.inline-node-hint {
  color: var(--ink-2);
  font-size: 0.76rem;
  line-height: 1.4;
}

.editor-card.preview-size-small .inline-node-title {
  padding: 8px 10px;
  font-size: 0.92rem;
}

.editor-card.preview-size-small .inline-node-summary-card {
  padding: 11px 12px;
}

.editor-card.preview-size-small .inline-node-summary-text,
.editor-card.preview-size-small .inline-node-hint {
  font-size: 0.7rem;
}

.editor-card.preview-size-small .inline-node-button-row {
  gap: 6px;
}

.editor-card.preview-size-large .inline-node-title {
  padding: 12px 14px;
  font-size: 1.05rem;
}

.editor-card.preview-size-large .inline-node-summary-card {
  padding: 16px 18px;
}

.editor-card.preview-size-large .inline-node-summary-text {
  font-size: 1rem;
}

.node-image {
  width: 100%;
  height: 118px;
  margin-top: 14px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(86, 63, 39, 0.08);
}

.reference-link {
  color: #d8e2ee;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.reference-link.pending {
  color: #c8a9a9;
}

.preview-panel {
  width: 248px;
  padding: 12px;
  pointer-events: none;
  z-index: 92;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
  will-change: opacity, transform;
}

.context-action-menu {
  width: min(280px, calc(100vw - 28px));
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(104, 116, 132, 0.22);
  background: linear-gradient(180deg, rgba(31, 36, 43, 0.98), rgba(22, 26, 33, 0.98));
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  z-index: 94;
}

.context-action-shell {
  display: grid;
  gap: 10px;
}

.context-action-shell h4 {
  margin: 2px 0 0;
  font-size: 1rem;
  line-height: 1.2;
}

.context-action-list {
  display: grid;
  gap: 8px;
}

.context-action-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 15px;
  border: 1px solid rgba(104, 116, 132, 0.16);
  background: rgba(48, 55, 65, 0.78);
  text-align: left;
  color: var(--ink-1);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.context-action-item strong {
  font-size: 0.88rem;
  line-height: 1.15;
}

.context-action-item span {
  color: var(--ink-2);
  font-size: 0.74rem;
  line-height: 1.35;
}

.context-action-item:hover {
  background: rgba(61, 70, 82, 0.92);
  border-color: rgba(145, 159, 178, 0.22);
  transform: translateY(-1px);
}

.preview-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.preview-panel.is-hiding {
  opacity: 0;
  transform: translateY(8px);
}

.preview-panel.is-search-preview {
  width: min(720px, calc(100vw - 430px));
  max-height: min(78vh, 760px);
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(109, 122, 140, 0.22);
  background: linear-gradient(180deg, rgba(31, 36, 43, 1), rgba(19, 23, 29, 1));
  box-shadow: var(--shadow-lg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: hidden;
}

.preview-panel.is-external-preview {
  width: min(340px, calc(100vw - 48px));
  padding: 12px;
  border-radius: 20px;
  border: 1px solid rgba(109, 122, 140, 0.22);
  background: linear-gradient(180deg, rgba(31, 36, 43, 0.98), rgba(19, 23, 29, 0.98));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.preview-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.preview-metrics span {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--ink-1);
  font-size: 0.7rem;
  line-height: 1;
  background: rgba(52, 60, 70, 0.88);
  box-shadow: inset 0 0 0 1px rgba(111, 124, 140, 0.12);
}

.neuron-context-panel {
  position: absolute;
  top: 94px;
  right: 46px;
  z-index: 35;
  width: min(210px, calc(100vw - 28px));
  padding: 9px 9px 8px;
  border-radius: 16px;
  background: rgba(31, 36, 43, 0.94);
  pointer-events: auto;
}

.neuron-context-panel h4 {
  margin: 0 0 4px;
  font-size: 0.88rem;
  line-height: 1.12;
}

.neuron-context-panel p {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.68rem;
  line-height: 1.3;
}

.neuron-context-groups {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.neuron-context-group {
  display: grid;
  gap: 4px;
  padding: 6px 7px;
  border-radius: 11px;
  background: rgba(45, 51, 60, 0.62);
  box-shadow: inset 0 0 0 1px rgba(102, 113, 128, 0.08);
}

.neuron-context-group h5 {
  margin: 0;
  color: var(--ink-0);
  font-size: 0.6rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.neuron-context-links {
  display: grid;
  gap: 5px;
}

.neuron-context-link {
  display: grid;
  gap: 2px;
  padding: 5px 6px;
  border-radius: 10px;
  background: rgba(37, 43, 51, 0.84);
}

.neuron-context-link strong {
  color: var(--ink-0);
  font-size: 0.74rem;
  font-weight: 700;
}

.neuron-context-link span,
.neuron-context-empty {
  color: var(--ink-2);
  font-size: 0.67rem;
  line-height: 1.28;
}

.neuron-context-empty {
  margin: 0;
}

.viewport-nav {
  z-index: 36;
  pointer-events: auto;
}

.viewport-nav-horizontal {
  left: 50%;
  bottom: 18px;
  width: min(420px, calc(100vw - 150px));
  transform: translateX(-50%);
  padding: 8px 12px;
}

.viewport-nav-vertical {
  top: 132px;
  right: 14px;
  bottom: 94px;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  border-radius: 16px;
  background: rgba(34, 39, 46, 0.88);
}

.viewport-zoom-panel {
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.viewport-slider {
  margin: 0;
  accent-color: var(--accent-strong);
}

.viewport-slider-horizontal {
  width: 100%;
}

.viewport-slider-vertical {
  width: 186px;
  transform: rotate(-90deg);
}

.viewport-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.viewport-zoom-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
}

.viewport-zoom-indicator {
  min-width: 62px;
  padding: 8px 10px;
  border-radius: 12px;
  text-align: center;
  color: var(--ink-1);
  background: rgba(49, 56, 65, 0.88);
  box-shadow: inset 0 0 0 1px rgba(101, 112, 126, 0.16);
}

.preview-panel h4 {
  margin: 0 0 8px;
}

.preview-panel > p,
.preview-panel .preview-metrics + p,
.search-preview-header > div > p {
  margin: 0;
  color: var(--ink-1);
  font-size: 0.9rem;
  line-height: 1.5;
}

.search-preview-editor {
  color: #241d18;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.preview-thumb {
  width: 100%;
  height: 110px;
  margin: 10px 0;
  border-radius: 16px;
  object-fit: cover;
}

.search-preview-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
}

.external-link-preview-shell {
  display: grid;
  gap: 10px;
}

.external-link-preview-header h4 {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.2;
}

.external-link-preview-header p:last-child {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 0.74rem;
  line-height: 1.35;
}

.external-link-preview-frame-shell {
  display: grid;
  gap: 6px;
}

.external-link-preview-frame {
  width: 100%;
  height: 168px;
  border: 0;
  border-radius: 14px;
  background: rgba(13, 16, 21, 0.92);
}

.external-link-preview-fallback {
  color: var(--ink-2);
  font-size: 0.68rem;
  line-height: 1.3;
}

.search-preview-header h4 {
  margin: 4px 0 0;
  font-size: clamp(1.16rem, 1.5vw, 1.5rem);
}

.search-preview-editor {
  min-height: 280px;
  max-height: min(58vh, 560px);
  overflow: auto;
  pointer-events: none;
}

.mention-suggestions,
.search-results {
  min-width: 240px;
  max-width: 320px;
  max-height: 320px;
  overflow: auto;
  padding: 8px;
}

.mention-suggestions {
  z-index: 95;
}

.search-results {
  top: calc(100% + 8px);
  left: 0;
  right: 0;
}

.top-search-results {
  top: calc(100% + 10px);
}

.suggestion-item,
.search-item {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  color: var(--ink-1);
}

.suggestion-item:hover,
.suggestion-item.active,
.search-item:hover {
  background: rgba(91, 102, 117, 0.34);
}

.search-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-0);
}

.search-highlight {
  padding: 0 2px;
  border-radius: 4px;
  background: rgba(244, 208, 63, 0.88);
  color: #2a2110;
  box-shadow: 0 0 0 1px rgba(255, 231, 151, 0.16);
}

.edge-branch {
  stroke: rgba(176, 194, 213, 0.48);
  stroke-width: 2.35;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: none;
  pointer-events: none;
}

.edge-hit-area {
  stroke: rgba(255, 255, 255, 0.001);
  stroke-width: 52;
  fill: none;
  pointer-events: all;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: text;
}

.edge-reference {
  stroke: rgba(129, 145, 166, 0.52);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 8 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

body.canvas-performance-simplified .edge-branch,
body.canvas-performance-simplified .edge-reference,
body.canvas-performance-simplified .edge-hovered {
  filter: none;
}

.edge-selected {
  stroke: rgba(221, 231, 241, 0.84);
  stroke-width: 2.9;
}

.edge-hovered {
  stroke: rgba(232, 239, 246, 0.96);
  stroke-width: 3.2;
  filter: none;
}

.edge-label-text {
  fill: #e9eef5;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  paint-order: stroke;
  stroke: rgba(24, 29, 36, 0.96);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: auto;
  cursor: pointer;
}

.edge-label-editor-shell {
  overflow: visible;
  pointer-events: none;
}

.edge-label-editor-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.edge-label-editor-input {
  width: 100%;
  height: 100%;
  padding: 5px 10px;
  border: 1px solid rgba(157, 176, 199, 0.4);
  border-radius: 999px;
  background: rgba(26, 31, 38, 0.94);
  color: #eef4fb;
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
  outline: none;
}

.edge-label-editor-input:focus {
  border-color: rgba(208, 223, 240, 0.66);
  box-shadow: 0 0 0 2px rgba(138, 170, 210, 0.18), 0 10px 24px rgba(0, 0, 0, 0.24);
}

@keyframes neuronPulse {
  0%, 100% {
    transform: rotate(var(--bubble-tilt)) scale(1);
    box-shadow:
      0 10px 24px var(--bubble-glow),
      0 0 18px rgba(232, 240, 248, 0.06),
      inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
  50% {
    transform: rotate(calc(var(--bubble-tilt) + 1.2deg)) scale(1.03);
    box-shadow:
      0 14px 30px var(--bubble-glow),
      0 0 24px rgba(232, 240, 248, 0.1),
      inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}

body.canvas-performance-hide-context .context-layer {
  display: none;
}

body.canvas-performance-simplified .context-node {
  filter: none;
  opacity: 0.46;
}

body.canvas-performance-simplified .node-card h3,
body.canvas-performance-simplified .context-node h3 {
  text-shadow: none;
}

@media (max-width: 860px) {
  body.touch-ui .mobile-view-switch {
    display: flex;
  }

  body.mobile-explorer-active .mobile-explorer {
    display: block;
  }

  body.mobile-explorer-active .canvas-stage,
  body.mobile-explorer-active .grid-backdrop,
  body.mobile-explorer-active .neuron-context-panel,
  body.mobile-explorer-active .viewport-nav,
  body.mobile-explorer-active .top-search-shell,
  body.mobile-explorer-active .neuron-tabbar-shell {
    display: none;
  }

  .control-menu {
    width: 100%;
    padding: 12px;
  }

  .menu-panel {
    border-radius: 24px;
    padding: 18px;
  }

  .session-menu {
    padding: 50px 12px 12px 0;
  }

  .button-strip {
    grid-template-columns: 1fr;
  }

  .menu-toggle-button {
    top: 12px;
    left: 12px;
  }

  .neuron-tabbar-shell {
    top: 12px;
    left: 82px;
    right: 12px;
  }

  .viewport-nav-horizontal {
    width: min(360px, calc(100vw - 118px));
    bottom: 12px;
  }

  .viewport-nav-vertical {
    top: 96px;
    right: 12px;
    bottom: 82px;
    width: 34px;
  }

  .viewport-zoom-panel {
    right: 12px;
    bottom: 12px;
  }

  .document-sheet-backdrop {
    padding: 16px;
  }

  .document-sheet-card {
    width: min(100%, calc(100vw - 32px));
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: 18px;
  }

  .node-card h3 {
    font-size: 1rem;
  }
}

@media (max-width: 640px) {
  .top-layout {
    left: 12px;
    right: 12px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "center"
      "right"
      "meta";
    gap: 8px;
  }

  .top-layout-left {
    grid-template-columns: 50px minmax(0, 1fr);
  }

  .top-layout-right {
    justify-items: stretch;
  }

  .mobile-view-switch {
    top: 118px;
  }

  .mobile-explorer {
    padding-top: 164px;
  }

  .control-menu,
  .session-menu {
    width: min(100vw - 12px, 360px);
  }

  .session-toolbar {
    max-width: none;
    justify-content: flex-start;
  }

  .save-meta-bar {
    max-width: none;
    justify-content: flex-start;
  }

  .session-menu {
    padding-top: 76px;
  }

  .neuron-context-panel {
    top: 92px;
    right: 12px;
    width: min(204px, calc(100vw - 24px));
  }

  .session-button {
    min-height: 32px;
    padding: 7px 9px;
    font-size: 0.8rem;
  }

  .session-button-label {
    display: none;
  }

  .session-button strong {
    max-width: 118px;
  }

  .brand-block h1,
  .panel-head h2 {
    font-size: 1rem;
  }

  .inline-node-actions {
    flex-direction: column;
  }

  .document-sheet-header,
  .document-sheet-footer {
    flex-direction: column;
  }

  .document-sheet-header-actions {
    justify-content: flex-start;
  }

  .document-sheet-editor {
    min-height: 0;
    padding: 22px;
  }

  .neuron-tabbar-shell {
    left: 12px;
    right: 12px;
    top: 82px;
  }

  .viewport-nav-horizontal {
    left: 50%;
    width: min(300px, calc(100vw - 96px));
    bottom: 12px;
  }

  .viewport-nav-vertical {
    top: 132px;
    right: 12px;
    bottom: 94px;
    width: 32px;
  }

  .viewport-zoom-panel {
    left: 50%;
    right: auto;
    bottom: 58px;
    transform: translateX(-50%);
    gap: 6px;
  }

  .viewport-zoom-indicator {
    min-width: 54px;
    font-size: 0.88rem;
  }

  .tab-pill {
    max-width: min(220px, calc(100vw - 48px));
  }

  .inline-node-button-row {
    width: 100%;
    justify-content: flex-start;
  }
}

body.touch-ui .canvas-viewport {
  touch-action: none;
}

body.touch-ui .viewport-nav,
body.touch-ui .viewport-slider,
body.touch-ui .viewport-zoom-button {
  touch-action: manipulation;
}

body.touch-ui .menu-toggle-button:hover,
body.touch-ui .menu-close-button:hover,
body.touch-ui .primary-button:hover,
body.touch-ui .secondary-button:hover,
body.touch-ui .ghost-button:hover,
body.touch-ui .danger-button:hover,
body.touch-ui .tab-button:hover,
body.touch-ui .tab-close:hover,
body.touch-ui .node-card:hover,
body.touch-ui .node-quick-add:hover,
body.touch-ui .suggestion-item:hover,
body.touch-ui .search-item:hover,
body.touch-ui .document-sheet-editor .document-reference-link:hover,
body.touch-ui .brain-title-button:hover,
body.touch-ui .context-action-item:hover,
body.touch-ui .inline-node-summary-card:hover {
  transform: none;
  filter: none;
}
