/* Mece canvas: geometry, level headers, nodes, connectors, badges (PLAN 6.3, 6.5, 6.6, 11.1). */
:root {
  --node-w: 240px;
  --root-w: 280px;
  --node-min-h: 48px;
  --node-pad: 12px 14px;
  --node-lines: 6;
  --h-gap: 96px;
  --v-gap: 16px;
  --group-gap: 28px;
  --sowhat-offset: 120px;
  --headers-h: 36px;
}

@media (max-width: 767px) {
  :root {
    --node-w: 200px;
    --root-w: 220px;
    --node-min-h: 44px;
    --node-pad: 10px 12px;
    --h-gap: 56px;
    --v-gap: 12px;
    --group-gap: 20px;
    --sowhat-offset: 72px;
  }
}

/* Level header strip: follows pan/zoom horizontally, fixed vertically. */
.headers {
  position: absolute; top: 0; left: 0; right: 0;
  height: var(--headers-h); z-index: 30;
  overflow: hidden; pointer-events: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header {
  position: absolute; top: 0; height: var(--headers-h);
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px; white-space: nowrap; overflow: hidden;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.header__glyph { font-size: 12px; letter-spacing: 0; }
.header__glyph--ok { color: var(--ok); }
.header__glyph--warn { color: var(--warn); }
.header__glyph--bad { color: var(--bad); }
.header__glyph--stale { color: var(--stale); }
.header__cut { font-weight: 600; color: var(--muted); opacity: .85; }

/* World: one transformed layer holding the SVG connectors and the HTML nodes. */
#world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.connectors { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.connector { fill: none; stroke: var(--line); stroke-width: 1.5; }
.connector--ghost { stroke: var(--teal); stroke-dasharray: 4 4; }
.nodes { position: absolute; top: 0; left: 0; }

.node {
  position: absolute; top: 0; left: 0;
  width: var(--node-w); min-height: var(--node-min-h);
  padding: var(--node-pad);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-node);
  color: var(--ink);
  font-size: 14px; line-height: 20px; font-weight: 400;
  overflow: visible;
  will-change: transform;
}
.node:hover { border-color: var(--line); box-shadow: var(--shadow-hover); }
.node.is-selected { border: 2px solid var(--teal); box-shadow: var(--shadow-selected); }
.node--root {
  width: var(--root-w);
  background: var(--navy); border: none; color: #FFFFFF;
  font-size: 16px; line-height: 22px; font-weight: 600;
}
.node--root:hover { background: var(--navy-hover); border: none; }
.node--l1 { box-shadow: inset 4px 0 0 var(--teal); }
.node--l1:hover { box-shadow: inset 4px 0 0 var(--teal), var(--shadow-hover); }
.node--leaf { border-right: 3px solid var(--muted); }

.node__text {
  display: -webkit-box;
  -webkit-line-clamp: var(--node-lines);
  line-clamp: var(--node-lines);
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.node--empty .node__text { color: var(--muted); font-style: italic; }

/* Ghost = Mece suggestion, not yet accepted (PLAN 6.3). */
.node--ghost {
  border: 1.5px dashed var(--teal);
  background: rgba(230,244,243,.5);
  padding-top: 22px;
}
.node--ghost .node__text { font-style: italic; color: #3D5A73; }
.node__tag {
  position: absolute; top: 5px; left: 12px;
  font-size: 10px; line-height: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; font-style: normal;
  color: var(--teal);
}

/* Verdict badge: 18px circle, overlaps the border by 6px, colour + glyph. */
.node__badge {
  position: absolute; top: -12px; left: -12px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; line-height: 1; font-weight: 700;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border);
}
.node__badge--ok { background: var(--ok); border-color: var(--ok); color: #FFFFFF; }
.node__badge--warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.node__badge--bad { background: var(--bad); border-color: var(--bad); color: #FFFFFF; }
.node__badge.is-stale { opacity: .5; }

/* Inline editing (§6.3: "Editing: same as selected, text becomes <textarea> auto-growing").
   P1 edits the root bubble in the root stage and the first empty L1 bubble (§4.3); P2
   generalises it to every node. */
.node.is-editing { border: 2px solid var(--teal); box-shadow: var(--shadow-selected); }
.node--root.is-editing { border: 2px solid var(--teal); background: var(--navy); }
.node__edit {
  display: block; width: 100%; min-height: 20px; margin: 0; padding: 0;
  border: 0; background: none; color: inherit;
  font: inherit; line-height: inherit;
  resize: none; overflow: hidden;
}
.node__edit:focus { outline: none; }
.node--root .node__edit { font: 600 16px/22px var(--font-sans); color: #FFFFFF; }
.node__edit::placeholder { color: var(--muted); font-style: italic; }
.node--root .node__edit::placeholder { color: rgba(255, 255, 255, .72); font-style: italic; }

/* Hidden measuring host (PLAN 11.1). */
#measure { position: absolute; top: 0; left: -9999px; visibility: hidden; pointer-events: none; }
#measure .node { position: absolute; transform: none !important; }

/* Badges and tags are display:grid/flex children, so the hidden attribute needs a hand. */
.node__badge[hidden], .node__tag[hidden],
.header__glyph[hidden], .header__cut[hidden] { display: none; }

@media (max-width: 767px) {
  .node__edit { font-size: 16px; }          /* inputs >= 16px: no iOS zoom (§21.17) */
  .node--root .node__edit { font-size: 16px; line-height: 22px; }
}
