/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #faf9f6; }
body { font-family: 'Georgia', serif; }

/* ── Canvas ── */
#app {
  width: 100vw; height: 100vh; position: relative; overflow: hidden;
  background: #faf9f6;
  background-image: radial-gradient(circle, #ddd9ce 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── Nodes Framework ── */
.node {
  position: absolute;
  background: #fffef9;
  border-radius: 4px;
  min-width: 120px;
  max-width: 280px;
  overflow: visible;
  font-size: 13.5px;
  line-height: 1.65;
  color: #2a2820;
  cursor: grab;
  user-select: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 0.5px #c4bfb0, 0 1px 4px rgba(0,0,0,0.05);
  transition: box-shadow .12s;

  /* Node States */
  &:hover {
    box-shadow: 0 0 0 0.5px #8a8478, 0 2px 8px rgba(0,0,0,0.08);
    & .node-x { opacity: 1; }
    & .node-hbar { height: 22px; opacity: 1; pointer-events: all; }
  }

  &.selected {
    z-index: 20;
    box-shadow: 0 0 0 1.5px #5a5248, 0 0 0 3.5px rgba(90,82,72,0.12), 0 2px 8px rgba(0,0,0,0.08);
  }

  &.edge-target {
    box-shadow: 0 0 0 2px rgba(64,140,220,0.7), 0 2px 8px rgba(0,0,0,0.08);
  }

  &.dismissing {
    animation: node-dismiss 0.22s cubic-bezier(.4,0,.6,1) forwards;
    pointer-events: none;
  }

  /* ── Node Sub-variants ── */
  &.synthesis-node {
    background: #eee9de;
    box-shadow: 0 0 0 1px #9a9080, 0 1px 6px rgba(0,0,0,0.07);
    max-width: 320px;

    &:hover { box-shadow: 0 0 0 1px #7a7060, 0 2px 8px rgba(0,0,0,0.1); }
    & .node-clip { max-height: 480px; }
    & .node-inner { font-style: normal; }
  }

  &.processing-node {
    background: #f0ede4;
    min-width: 160px;
    max-width: 280px;
    box-shadow: none;
    outline: 1px dashed #b8b090;
  }

  &.bot-node {
    background: #f6f4ee;
    outline: 0.5px dashed #afa89a;
    box-shadow: none;
    &:hover { outline-color: #7a7060; }
  }

  &.comment-node {
    background: #f8f6f0;
    box-shadow: 0 0 0 0.5px #c4bfb0, inset 2.5px 0 0 #9a9080;
  }

  &.artifact-node {
    background: #f3f0e8;
    box-shadow: 0 0 0 1px #b8b09a, 0 1px 4px rgba(0,0,0,0.05);
    min-width: 220px;
    max-width: 340px;
  }

  &.instrument-node {
    background: #f5f2ea;
    min-width: 190px;
    max-width: 300px;
    outline: 1px dashed #a09880;
    box-shadow: none;
  }

  &.image-node {
    background: #f3f0e8;
    min-width: 120px;
    max-width: 320px;
    & .node-clip { max-height: 340px; }
    & img {
      display: block; width: 100%; height: auto;
      border-radius: 3px; pointer-events: none; user-select: none;
    }
  }

  &.document-node {
    background: #f8f7f2;
    min-width: 220px;
    max-width: 360px;
    box-shadow: 0 0 0 0.5px #b8b4a4, 0 1px 5px rgba(0,0,0,0.06);

    &:hover { box-shadow: 0 0 0 0.5px #8a8478, 0 2px 8px rgba(0,0,0,0.09); }
    & .node-clip { max-height: 420px; }
  }

  &.action-set-node {
    background: #f5f2ea;
    min-width: 160px;
    max-width: 280px;
    overflow: visible;
    & .node-clip { max-height: 400px; }
  }
}

/* ── Node Internals ── */
.node-clip {
  display: flex; flex-direction: column; flex: 1;
  max-height: 420px; min-height: 0; position: relative;
  overflow: hidden; border-radius: 4px; border: none;
}

.node-inner {
  padding: 10px 28px 10px 13px; flex: 1;
  position: relative; overflow-y: auto; min-height: 0;
}
.image-inner { padding: 8px; }

.node-tag {
  font-size: 10px; color: #9a9080; letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 4px; font-family: system-ui, sans-serif;
}

.node-content { outline: none; min-height: 20px; word-break: break-word; }
.node-content-mixed { outline: none; min-height: 20px; word-break: break-word; cursor: text; }

.span-agent {
  display: block; font-style: italic; user-select: text;
  cursor: text; pointer-events: all; outline: none;

  & p { margin: 0 0 0.6em; }
  & p:last-child { margin-bottom: 0; }
  & ul, & ol { padding-left: 1.4em; margin: 0.3em 0 0.6em; list-style-position: outside; }
  & li { margin-bottom: 0.2em; }
  & strong { font-weight: 600; font-style: normal; }
  & code {
    font-family: var(--font-mono, monospace); font-size: 0.88em;
    background: rgba(0,0,0,0.06); padding: 1px 4px;
    border-radius: 2px; font-style: normal;
  }
}

.span-user {
  display: block; font-style: normal; cursor: text; outline: none; min-height: 1em;
  &:empty::before { content: ''; display: inline-block; }
}

.node-x {
  position: absolute; top: 6px; right: 7px;
  font-size: 14px; color: #c8c0b0; cursor: pointer; background: none;
  border: none; line-height: 1; opacity: 0; transition: opacity .12s;
  font-family: sans-serif; padding: 0; z-index: 3;
}

.node-hbar {
  height: 0; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 1px;
  opacity: 0; transition: opacity .15s, height .1s; pointer-events: none;

  & button {
    font-size: 10px; color: #7a7060; background: rgba(255,253,248,0.97);
    border: 0.5px solid #d0ccc0; border-top: none; border-radius: 0 0 3px 3px;
    padding: 3px 8px; cursor: pointer; font-family: system-ui, sans-serif;
    transition: background .1s; white-space: nowrap;

    &:hover { background: #ede9e0; color: #2a2820; }
  }
}

/* ── Global LM Italics ── */
.node.synthesis-node .synthesis-md,
.node.bot-node .synthesis-md,
.node.comment-node .synthesis-md,
.edge-label-overlay.lm-label .edge-label-text {
  font-style: italic;
}

/* ── Markdown Blocks ── */
.synthesis-md {
  font-style: italic; line-height: 1.7; user-select: text; cursor: text;

  & p { margin: 0 0 0.6em; }
  & p:last-child { margin-bottom: 0; }
  & h1, & h2, & h3 {
    font-style: normal; font-weight: 500; margin: 0.5em 0 0.3em;
    font-size: 1em; color: #3a3020;
  }
  & ul, & ol { padding-left: 1.2em; margin: 0.3em 0 0.6em; }
  & li { margin-bottom: 0.2em; }
  & strong { font-weight: 600; font-style: normal; color: #2a2820; }
  & em { font-style: italic; }
  & code {
    font-family: var(--font-mono, monospace); font-size: 0.88em;
    background: rgba(0,0,0,0.06); padding: 1px 4px;
    border-radius: 2px; font-style: normal;
  }
}

.md-block {
  position: relative; padding-right: 18px;
  &:last-child p, &:last-child li { margin-bottom: 0; }

  & .md-popout {
    position: absolute; right: 0; top: 1px;
    background: none; border: none; cursor: pointer; font-size: 9px;
    color: #c4bfb0; opacity: 0; transition: opacity .12s, color .1s;
    padding: 1px 2px; line-height: 1; font-family: system-ui, sans-serif;
    
    &:hover { color: #5a5248; }
  }
  
  &:hover .md-popout { opacity: 1; }
}

/* ── Provenance ── */
.prov-btn {
  font-size: 10px; color: #9a9080; cursor: pointer; background: none;
  border: none; padding: 2px 0 0; text-decoration: underline;
  text-underline-offset: 2px; font-family: system-ui, sans-serif; display: block;
}
.prov-body {
  display: none; font-size: 11px; color: #7a7060; border-top: 0.5px solid #d8d4c8;
  margin-top: 4px; padding-top: 4px; font-style: normal;
  font-family: system-ui, sans-serif; line-height: 1.5;
}

/* ── Feature Specific Node Internals ── */
.processing-body {
  padding: 12px 14px; font-family: system-ui, sans-serif; font-size: 12px;
  color: #7a7060; display: flex; align-items: center; gap: 8px;
}
.processing-spinner {
  width: 12px; height: 12px; border: 1.5px solid #d8d4c8;
  border-top-color: #7a6f5a; border-radius: 50%;
  animation: spin .8s linear infinite; flex-shrink: 0;
}

.header-btn {
  font-size: 10px; color: #9a9080; background: none; border: none;
  cursor: pointer; padding: 1px 4px; border-radius: 3px; font-family: system-ui, sans-serif;
  transition: background .1s; line-height: 1.4;
  &:hover { background: #ede9e0; color: #2a2820; }
}

.inst-header {
  padding: 7px 28px 5px 11px; font-size: 10px; color: #7a6f5a; letter-spacing: .06em;
  text-transform: uppercase; border-bottom: 0.5px solid #d8d2c4; font-family: system-ui, sans-serif;
  display: flex; align-items: center; gap: 6px;
}
.inst-body {
  padding: 9px 11px; font-family: system-ui, sans-serif;
  & label { font-size: 11px; color: #7a7060; display: block; margin-bottom: 3px; }
}

.ifield {
  margin-bottom: 8px;
  & input[type=text] {
    width: 100%; border: 0.5px solid #c4bfb0; border-radius: 3px; padding: 4px 8px;
    font-size: 12px; font-family: system-ui, sans-serif; background: #fffef9; color: #2a2820; outline: none;
  }
  & input[type=range] { width: 100%; accent-color: #7a6f5a; }
  & select {
    width: 100%; border: 0.5px solid #c4bfb0; border-radius: 3px; padding: 4px 7px;
    font-size: 12px; font-family: system-ui, sans-serif; background: #fffef9; color: #2a2820; outline: none;
  }
}

.iradio-group, .icheckbox-group { display: flex; flex-direction: column; gap: 4px; margin-top: 3px; }
.iradio-opt, .icheckbox-opt { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #2a2820; cursor: pointer; }
.iradio-opt input[type=radio], .icheckbox-opt input[type=checkbox] { flex-shrink: 0; margin: 0 5px 0 0; }

.radio-other-label { color: #9a9080; flex-shrink: 0; }
.radio-other-input {
  flex: 1; min-width: 0; border: none; border-bottom: 0.5px solid #c4bfb0; background: transparent;
  font-size: 12px; font-family: system-ui, sans-serif; color: #2a2820; outline: none;
  padding: 0 2px; margin-left: 4px; transition: border-color .1s;
  &:focus { border-bottom-color: #7a6f5a; }
  &:disabled { color: #b0a890; cursor: default; }
}

.ibtns { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; padding-top: 7px; border-top: 0.5px solid #e0dcd2; }
.ibtn {
  font-size: 11.5px; color: #4a4030; background: #eee9de; border: 0.5px solid #c4bfb0;
  border-radius: 3px; padding: 4px 11px; cursor: pointer; font-family: system-ui, sans-serif; transition: background .1s;
  &:hover { background: #e0dcd0; }
  &.primary { background: #2a2820; color: #faf9f6; border-color: #2a2820; }
  &.primary:hover { background: #4a4438; }
}

.artifact-title {
  font-size: 10px; color: #7a7060; letter-spacing: .06em; text-transform: uppercase;
  padding: 7px 28px 5px 11px; border-bottom: 0.5px solid #d8d4c8; font-family: system-ui, sans-serif;
}
.artifact-body {
  padding: 9px 11px; font-size: 12.5px; line-height: 1.6; color: #2a2820; font-family: system-ui, sans-serif;
  & table { width: 100%; border-collapse: collapse; font-size: 12px; }
  & td, & th { padding: 4px 7px; border-bottom: 0.5px solid #e0dcd2; text-align: left; }
  & th { color: #7a7060; font-weight: 500; }
}

.doc-header {
  display: flex; align-items: center; gap: 6px; padding: 7px 28px 6px 11px;
  border-bottom: 0.5px solid #d8d4c8; font-family: system-ui, sans-serif; min-width: 0;
}
.doc-icon { font-size: 13px; color: #9a9080; flex-shrink: 0; line-height: 1; }
.doc-title {
  font-size: 11px; color: #5a5248; letter-spacing: .02em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; font-family: system-ui, sans-serif;
}

.doc-body {
  padding: 9px 13px; font-size: 12.5px; line-height: 1.65; color: #2a2820;
  overflow-y: auto; flex: 1; min-height: 0; user-select: text; cursor: text;

  & .synthesis-md { font-style: normal; }
  & p { margin: 0 0 0.55em; }
  & p:last-child { margin-bottom: 0; }
  & h1, & h2, & h3 { font-style: normal; font-weight: 500; margin: 0.6em 0 0.3em; font-size: 1em; color: #3a3020; }
  & ul, & ol { padding-left: 1.2em; margin: 0.3em 0 0.5em; }
  & li { margin-bottom: 0.15em; }
  & code {
    font-family: var(--font-mono, monospace); font-size: 0.88em;
    background: rgba(0,0,0,0.05); padding: 1px 4px; border-radius: 2px;
  }
}

.doc-footer {
  padding: 4px 13px 5px; border-top: 0.5px solid #e4e0d8; font-size: 10px;
  color: #b0a890; font-family: system-ui, sans-serif; letter-spacing: .03em; flex-shrink: 0;
}

.action-set-header {
  padding: 6px 28px 5px 11px; font-size: 10px; color: #7a6f5a; letter-spacing: .06em;
  text-transform: uppercase; border-bottom: 0.5px solid #d8d2c4; font-family: system-ui, sans-serif;
  display: flex; align-items: center; position: relative;
}
.action-set-title { flex: 1; }
.action-set-body { padding: 7px 9px; display: flex; flex-direction: column; gap: 4px; }
.action-set-action {
  width: 100%; text-align: left; background: #eee9de; border: 0.5px solid #c4bfb0; border-radius: 4px;
  padding: 5px 10px; font-size: 12px; color: #2a2820; cursor: pointer; font-family: system-ui, sans-serif;
  transition: background .1s;
  &:hover:not(:disabled) { background: #e4dfd4; }
  &:disabled { color: #9a9080; cursor: default; }
}

/* ── Floating Toolbars & Menus ── */
#ctx-bar {
  position: fixed; bottom: 58px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px; background: rgba(255,253,248,0.92);
  border: 0.5px solid #c4bfb0; border-radius: 14px; padding: 4px 10px 4px 12px;
  z-index: 399; font-family: system-ui, sans-serif; font-size: 11px;
  backdrop-filter: blur(6px); box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  max-width: 480px; min-width: 180px; transition: bottom .2s;
}
body.trash-open #ctx-bar { bottom: 94px; }

#ctx-bar-label { font-size: 9.5px; color: #b0a890; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; flex-shrink: 0; }
#ctx-bar-preview {
  flex: 1; color: #9a9080; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; min-width: 0;
  &:empty::before { content: 'no context set'; color: #c4bfb0; }
  &.has-content { color: #5a5248; }
}

#ctx-bar-edit {
  background: none; border: none; cursor: pointer; color: #b0a890;
  font-size: 12px; padding: 0 2px; line-height: 1; flex-shrink: 0; transition: color .1s;
  &:hover { color: #5a5248; }
}

#ctx-bar-panel {
  position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%);
  width: 480px; z-index: 401; background: rgba(255,253,248,0.98); border: 0.5px solid #c4bfb0;
  border-radius: 10px; padding: 10px; box-shadow: 0 4px 18px rgba(0,0,0,0.1);
  font-family: system-ui, sans-serif; display: none;
  &.open { display: block; }
}
body.trash-open #ctx-bar-panel { bottom: 128px; }

#ctx-bar-textarea {
  width: 100%; min-height: 72px; max-height: 180px; border: 0.5px solid #c4bfb0; border-radius: 5px;
  padding: 7px 9px; font-size: 12px; line-height: 1.6; font-family: system-ui, sans-serif;
  color: #2a2820; background: #fffef9; resize: vertical; outline: none; display: block;
  &:focus { border-color: #7a6f5a; }
}

#ctx-bar-actions {
  display: flex; gap: 6px; margin-top: 7px; justify-content: flex-end;
  & button {
    font-size: 11px; padding: 3px 10px; border-radius: 9px; cursor: pointer; font-family: system-ui, sans-serif;
    border: 0.5px solid #c4bfb0; background: #eee9de; color: #4a4030; transition: background .1s;
    &:hover { background: #e0dcd0; }
  }
  & #ctx-bar-save {
    background: #2a2820; color: #faf9f6; border-color: #2a2820;
    &:hover { background: #4a4438; }
  }
}

#toolbar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; background: rgba(255,253,248,0.94);
  border: 0.5px solid #c4bfb0; border-radius: 22px; padding: 2px 7px; z-index: 400;
  font-family: system-ui, sans-serif; font-size: 11.5px; backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);

  @media screen and (max-width: 800px) { left: 20px; transform: none; }
}

.tb-btn {
  background: none; border: none; cursor: pointer; font-size: 11.5px; color: #6a6458;
  padding: 3px 8px; border-radius: 11px; transition: background .1s;
  font-family: system-ui, sans-serif; white-space: nowrap;

  &:hover { background: #ede9e0; color: #2a2820; }
  &.on { background: #2a2820; color: #faf9f6; }

  &#btn-clear { color: #8a2010; }
  &.tb-clear-confirm {
    background: #8a2010; border-radius: 11px;
    &#btn-clear { color: #fffef9; }
    &:hover { background: #a02a18; color: #fff; }
  }
}
.tb-sep { width: 0.5px; height: 14px; background: #c4bfb0; flex-shrink: 0; }

.tb-agent-group {
  display: flex; align-items: center; gap: 10px; padding: 2px 7px; border-radius: 14px;
  border: 0.5px solid transparent; transition: border-color .15s, background .15s;
}

.tb-eye { display: flex; align-items: center; justify-content: center; padding: 3px 6px; }
.eye-icon { display: block; flex-shrink: 0; }
#btn-agent .eye-open { display: none; }
#btn-agent .eye-closed { display: block; }
#btn-agent.on .eye-open { display: block; }
#btn-agent.on .eye-closed { display: none; }

.sens-wrap { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: #9a9080; white-space: nowrap; }
.sens-wrap input[type=range] { width: 50px; accent-color: #7a6f5a; }

#io-bar {
  position: fixed; bottom: 16px; right: 20px; display: flex; align-items: center; gap: 6px;
  background: rgba(255,253,248,0.94); border: 0.5px solid #c4bfb0; border-radius: 22px;
  padding: 6px 12px; z-index: 400; backdrop-filter: blur(6px); box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

#stext {
  font-size: 10.5px; color: #9a9080; font-family: system-ui, sans-serif; white-space: nowrap;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; transition: max-width 0.22s ease, opacity 0.15s ease;
  &.stext-hidden { max-width: 0; opacity: 0; }
}
#ws-status {
  width: 6px; height: 6px; border-radius: 50%; background: #d8d4c8; flex-shrink: 0; transition: background .3s;
  &.connected { background: #7a9060; }
  &.disconnected { background: #c87060; }
}

#hint {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); font-size: 11px;
  color: #b8b0a0; font-family: system-ui, sans-serif; pointer-events: none; white-space: nowrap;
  transition: opacity .4s; z-index: 10;
}
body.trash-open #hint { bottom: 92px; }

#sel-rect { position: absolute; border: 1px dashed #9a9080; background: rgba(122,111,90,0.04); pointer-events: none; display: none; z-index: 50; }

#ctx, #cluster-picker {
  position: fixed; z-index: 500; background: #fffef9; border: 0.5px solid #c4bfb0;
  border-radius: 8px; padding: 5px 0; box-shadow: 0 4px 18px rgba(0,0,0,0.1);
  font-family: system-ui, sans-serif; font-size: 12.5px; display: none; min-width: 170px;
}
#cluster-picker { z-index: 600; border-radius: 7px; padding: 4px 0; min-width: 150px; }

.ctx-section { padding: 3px 14px; font-size: 10px; color: #9a9080; letter-spacing: .06em; text-transform: uppercase; }
.ctx-row {
  padding: 7px 14px; cursor: pointer; color: #2a2820; display: flex; align-items: center; gap: 9px;
  &:hover { background: #f0ede4; }
  &.danger { color: #8a3020; }
  &.danger:hover { background: #faf0ee; }
}
.ctx-sep { height: 0.5px; background: #e0dcd2; margin: 4px 0; }

#cluster-picker-list .ctx-row { padding: 6px 13px; }
#cluster-picker-list .ctx-row:hover { background: #f0ede4; }

/* ── Trash Tray ── */
#trash {
  position: fixed; bottom: 0; left: 0; right: 0; background: rgba(250,249,246,0.96);
  border-top: 0.5px solid #d8d4c8; padding: 0 14px; display: flex; align-items: center;
  gap: 8px; z-index: 300; height: 0; overflow: hidden; transition: height .2s;
  &.has-items { height: 34px; }
  &.scrollable #trash-fade { opacity: 1; }
}

#trash.has-items ~ #toolbar, body.trash-open #toolbar, body.trash-open #io-bar { bottom: 52px; }

#trash-label { font-size: 10px; color: #9a9080; letter-spacing: .05em; text-transform: uppercase; font-family: system-ui, sans-serif; white-space: nowrap; flex-shrink: 0; }
#trash-items {
  display: flex; gap: 5px; flex-wrap: nowrap; overflow-x: auto; flex: 1; align-items: center; scrollbar-width: none;
  &::-webkit-scrollbar { display: none; }
}
#trash-fade {
  position: absolute; right: 0; top: 0; bottom: 0; width: 80px; pointer-events: none;
  background: linear-gradient(to left, rgba(250,249,246,0.97) 0%, rgba(250,249,246,0) 100%); opacity: 0; transition: opacity .15s;
}

.trash-chip {
  font-size: 10.5px; color: #7a7060; background: #eee9de; border: 0.5px solid #c4bfb0; border-radius: 11px;
  padding: 2px 9px; cursor: pointer; white-space: nowrap; font-family: system-ui, sans-serif; flex-shrink: 0;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
  &:hover { background: #e0dcd2; }
}

/* ── Cluster Layer ── */
#clusters-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: visible; }

.cluster-name-el {
  font-size: 10.5px; color: #6a6050; letter-spacing: .05em; font-family: system-ui, sans-serif;
  cursor: text; outline: none; display: inline-block; min-width: 30px; background: #faf9f6;
  padding: 1px 4px; border: 0.5px solid transparent; border-radius: 2px;
  &:focus { border-color: #9a9080; background: #fffef9; }
  &.lm-label { font-style: italic; }
}

.cluster-spinner { transform-box: fill-box; transform-origin: center; animation: cluster-spin 0.9s linear infinite; transition: opacity 0.18s ease; }
.cluster-dot-fading { transition: opacity 0.18s ease; }

/* ── Edge Labels ── */
.edge-label-overlay {
  position: absolute; pointer-events: all; transform: translate(-50%, -50%); display: inline-flex;
  align-items: center; border-radius: 6px; background: rgba(255,253,248,0.93);
  border: 0.5px solid rgba(196,191,176,0.85); min-width: 44px; max-width: 240px;
  font-family: system-ui, sans-serif; font-size: 11px; color: #2a2820; white-space: nowrap; cursor: text;
  padding: 2px 5px 2px 7px; transition: opacity .2s;

  &.blank { opacity: 0; pointer-events: all; }
  &.blank:hover, &.blank:focus-within { opacity: 1; }
  &.lm-label .edge-label-text { font-style: italic; }
}

.edge-line-group:hover + * .edge-label-overlay.blank { opacity: 1; }

.edge-label-text { flex: 1; overflow: hidden; text-overflow: ellipsis; outline: none; }
.edge-label-delete {
  border: none; background: transparent; cursor: pointer; font-size: 11px; padding: 0;
  margin-left: 5px; opacity: 0.45; color: #7a7060; flex-shrink: 0; transition: opacity .1s;
  &:hover { opacity: 1; }
}

.edge-proposal-pill { border-style: dashed; border-color: #b0a070; gap: 5px; }
.edge-proposal-label { font-style: italic; color: #5a5040; flex: 1; }
.edge-proposal-yes, .edge-proposal-no { background: none; border: none; cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; flex-shrink: 0; }
.edge-proposal-yes { color: #5a7a5a; }
.edge-proposal-yes:hover { color: #2a5a2a; }
.edge-proposal-no { color: #9a5050; }
.edge-proposal-no:hover { color: #6a2020; }

/* ── Overlays & Modals ── */
#drop-overlay {
  position: fixed; inset: 0; z-index: 1000; background: rgba(255,253,248,0.88); display: none;
  align-items: center; justify-content: center; pointer-events: none; font-family: system-ui, sans-serif;
  font-size: 18px; color: #7a6f5a; letter-spacing: .04em;
  &.active { display: flex; }
}
#drop-overlay-inner { border: 1.5px dashed #b0a890; border-radius: 12px; padding: 40px 60px; text-align: center; }

#bubble-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
.bubble-set { position: absolute; pointer-events: none; }

.bubble-btn {
  position: absolute; display: flex; align-items: center; gap: 4px; background: rgba(255,253,248,0.97);
  border: 0.5px solid #c4bfb0; border-radius: 18px; padding: 3px 9px 3px 7px; font-family: system-ui, sans-serif;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.07); transition: background .1s, border-color .1s;
  pointer-events: all; white-space: nowrap; opacity: 0; animation: bubble-in .14s ease forwards;

  &:hover { background: #f0ede4; border-color: #9a9080; }
}
.bubble-btn-ratify { border-style: dashed; border-color: #b0a070; }
.bubble-icon { font-size: 11px; line-height: 1; flex-shrink: 0; color: #9a9080; }
.bubble-label { font-size: 10.5px; font-style: italic; color: #5a5248; line-height: 1.3; }

.bubble-confirm-yes, .bubble-confirm-no { font-size: 12px; cursor: pointer; padding: 0 2px; transition: color .1s; font-style: normal; }
.bubble-confirm-yes { color: #5a7a5a; }
.bubble-confirm-yes:hover { color: #2a5a2a; }
.bubble-confirm-no { color: #9a5050; }
.bubble-confirm-no:hover { color: #6a2020; }

.bubble-dismiss {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,253,248,0.97);
  border: 0.5px solid #c4bfb0; font-size: 11px; color: #9a9080; cursor: pointer; display: flex;
  align-items: center; justify-content: center; pointer-events: all; line-height: 1; padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07); transition: background .1s, border-color .1s, color .1s;

  &:hover { background: #f0ede4; border-color: #9a9080; color: #5a5248; }
}

.readme-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 1000; &.open { display: flex; } }
.readme-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.readme-modal-panel {
  position: relative; z-index: 1001; width: min(920px, 94%); max-height: 86vh; background: #fffef9;
  border-radius: 8px; border: 0.5px solid #c4bfb0; box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  overflow: hidden; display: flex; flex-direction: column;
}
.readme-modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  border-bottom: 0.5px solid #e8e4da; font-family: system-ui, sans-serif; color: #5a5248; font-weight: 600;
}
.readme-modal-content {
  padding: 14px; overflow-y: auto; font-family: system-ui, sans-serif; color: #2a2820;
  background: #fffef9; line-height: 1.6; white-space: pre-wrap;
}
.readme-close { background: none; border: none; cursor: pointer; font-size: 16px; padding: 6px; color: #9a9080; border-radius: 6px; &:hover { color: #2a2820; background: #ede9e0; } }

/* ── Animations ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes cluster-arrow-pulse     { 0% { opacity:1; } 20% { opacity:.05; } 65% { opacity:1; } 100% { opacity:1; } }
@keyframes cluster-arrow-pulse-out { 0% { opacity:1; } 20% { opacity:.05; } 65% { opacity:1; } 100% { opacity:0; } }
.cluster-arrow-pulse     { animation: cluster-arrow-pulse     0.55s ease-out forwards; }
.cluster-arrow-pulse-out { animation: cluster-arrow-pulse-out 0.55s ease-out forwards; }
@keyframes cluster-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes node-dismiss { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(40px) scale(0.96); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }