/* The board: gesture surface, dotted background, transformed world layer. */
.board {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;          /* we handle every gesture ourselves */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.4px);
  cursor: grab;
}
.board.moving { cursor: grabbing; }

.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.items-layer { position: absolute; left: 0; top: 0; }

.empty-hint {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 40%;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

/* ---- multi-select (R24) ---- */
.board.select-mode { cursor: crosshair; }
.select-box {
  position: absolute;
  left: 0;
  top: 0;
  border: 1.5px dashed var(--ink);
  border-radius: 10px;
  background: rgba(43, 42, 40, .06);
  pointer-events: none;
  z-index: 5;
}
/* Blobs the box touches, before the finger lifts. */
.item.box-hit > .item-jelly > .item-body { box-shadow: 0 0 0 3px rgba(255, 255, 255, .8), 0 4px 16px rgba(40, 30, 20, .22); }
/* Several selected: no per-item controls (✎, connect handle). */
.board.multi .item > .item-ctl { display: none; }

/* ---- lines (gooey strings), under the items ---- */
.links-layer {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}
/* Opacity on the group, so string and arrowheads blend as one shape. */
.link { opacity: .92; }
.link-goo, .link-heads { stroke: none; }
.link.selected > .link-goo, .link.selected > .link-heads {
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
  paint-order: stroke;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 4px rgba(40, 30, 20, .25));
}
/* Hover (mouse): the line lights up so you can see it's clickable. */
@media (hover: hover) {
  .link:not(.temp):not(.selected):hover > .link-goo,
  .link:not(.temp):not(.selected):hover > .link-heads {
    stroke: rgba(255, 255, 255, .9);
    stroke-width: 2px;
    paint-order: stroke;
    vector-effect: non-scaling-stroke;
    filter: brightness(1.06) drop-shadow(0 1px 4px rgba(40, 30, 20, .35));
  }
  .link-label:hover { box-shadow: 0 0 0 2px rgba(40, 30, 20, .3), 0 2px 8px rgba(40, 30, 20, .25); }
}

/* Wide invisible copy of the centre line: easy to tap on a phone. */
.link-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 22px;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
}
/* Straight style: thin, crisp, a bit more opaque. */
.link.straight { opacity: 1; }
.link.temp { pointer-events: none; }
.link.temp { opacity: .8; }
.link.temp.bad { opacity: .45; }
.link.temp.bad > .link-goo, .link.temp.bad > .link-tip { fill: var(--muted); }

/* + / − near each end and × in the middle of the selected line. Same
   on-screen size rule as the item controls. */
.link-ctls { position: absolute; left: 0; top: 0; z-index: 1000001; }
.link-ctl {
  position: absolute;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  box-shadow: var(--shadow-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: scale(max(min(calc(1 / var(--z, 1)), 1.18), calc(.6 / var(--z, 1))));
}
.link-del { color: var(--danger); }
.link-edit { font-size: 15px; }

/* Text on a line: a pill at its exact middle, filled with the line's
   colours, white border. Above blobs, below open trays (z 900000) and the
   dragged blob (z 1000000). */
.link-labels { position: absolute; left: 0; top: 0; z-index: 899999; }
.link-label {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 180px;
  padding: 3px 10px;
  border: 2px solid #fff;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 4px rgba(40, 30, 20, .18);
  cursor: pointer;
  width: max-content;
}
.link-label.selected { box-shadow: 0 0 0 2px rgba(40, 30, 20, .35), 0 2px 8px rgba(40, 30, 20, .25); }
.link-label[hidden] { display: none; }
@media (pointer: coarse) {
  .link-ctl { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
}

/* Tag filter (C6): a line between two faded blobs fades too. */
.link.faded, .link-label.faded { opacity: .2; }
