/* Grundfarben, Schriften und Radien kommen aus dem ecke.lt Design System (Tokens, index.html):
 * --bg, --surface, --text, --muted, --border, --accent, --danger, --badge-*, --font-*, --radius-*.
 * Hier stehen nur die Ableitungen für die Karte, als feste Hex-Werte, weil Cytoscape weder color-mix noch
 * Transparenz in Füllungen verlässlich liest. Gemischt aus Hintergrund und Akzent (8–20 %). */
:root {
  --surface-2: #f4f4f4;
  --accent-soft: #d4e5e8;
  --warn: var(--badge-lang);
  --warn-soft: #efe1d4;
  --info: var(--badge-arch);
  --info-soft: #e2deeb;
  --group-product: #e6eff0;
  --group-product-border: #8abbc7;
  --group-external: #f0ede5;
  --group-external-border: #c0b289;
  --node: var(--surface);
  --node-border: #aba9ab;
  --node-external: #f9f7f3;
  --node-external-border: var(--badge-lead);
  --node-actor: #e2deeb;
  --node-actor-border: var(--badge-arch);
  --edge-comm: #898789;
  --edge-deploy: var(--badge-lang);
  --edge-label-bg: var(--bg);
  --select: var(--text);
  --delta-added: var(--badge-ai);
  --delta-added-soft: #e0e7d4;
  --delta-changed: var(--badge-lead);
  --delta-changed-soft: #e7e2d4;
  --delta-removed: var(--badge-ux);
  --delta-removed-soft: #efd7dd;
  --radius: var(--radius-lg);
  font-family: var(--font-ui);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-2: #39373a;
    --accent-soft: #2c3f43;
    --warn-soft: #463229;
    --info-soft: #363345;
    --group-product: #243033;
    --group-product-border: #4d848b;
    --group-external: #352f23;
    --group-external-border: #988244;
    --node-border: #807e80;
    --node-external: #3c3732;
    --node-actor: #363345;
    --edge-comm: #969595;
    --delta-added-soft: #363f2c;
    --delta-changed-soft: #473e29;
    --delta-removed-soft: #472730;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; overflow: hidden; }
a { color: var(--accent); }
code, .mono { font-family: var(--font-mono); font-size: 12px; }
button, select, input { font: inherit; color: inherit; }

/* Karte füllt das Fenster, Bedienelemente schweben zurückhaltend darüber */
.map { position: fixed; inset: 0; }
#cy { position: absolute; inset: 0; }
.hud-top { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 2; }
.hud-top > * { pointer-events: auto; }
.brand { min-width: 0; padding: 2px 4px; }
.brand h1 { font-family: var(--font-heading); font-size: 15px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.toolbar { display: flex; gap: 4px; align-items: center; flex: none; padding: 3px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.seg { display: inline-flex; }
.seg button { font-size: 12px; background: none; border: 0; border-radius: 7px; padding: 4px 8px; min-height: 28px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface-2); color: var(--text); }
.seg button:disabled { opacity: .35; cursor: default; }
.icon { position: relative; width: 30px; height: 30px; display: inline-grid; place-items: center; background: none; border: 0; border-radius: 7px; color: var(--muted); cursor: pointer; }
.icon:hover, .seg button:not(:disabled):hover { color: var(--text); }
.icon[aria-expanded=true], .icon.active { background: var(--surface-2); color: var(--text); }
.icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon .dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.icon .badge { position: absolute; top: -3px; right: -4px; }
.badge { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 10px; line-height: 16px; text-align: center; }

.popover { position: absolute; top: 52px; right: 12px; z-index: 3; width: min(300px, calc(100% - 24px)); display: grid; gap: 8px;
  padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 24px rgb(0 0 0 / .12); }
.popover label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.popover input[type=search], .popover select, .popover button, .popover .button {
  font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-height: 32px; width: 100%; }
.popover .toggle { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; }
.popover .row { display: flex; gap: 6px; }
.popover .row > * { flex: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.legend { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; max-width: calc(100% - 24px);
  padding: 4px 8px; border-radius: 8px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 4px; }
.legend i.dash { border-top-style: dashed; }
.legend b { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid; vertical-align: middle; margin-right: 4px; }
.status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); background: var(--bg); z-index: 1; }
.status.error { color: var(--warn); }

.dropzone { position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--accent) 18%, transparent); border: 3px dashed var(--accent); color: var(--text); z-index: 10; pointer-events: none; }

/* Kurzkarte am markierten Element */
.peek { position: absolute; z-index: 2; width: min(300px, calc(100% - 16px)); padding: 8px 8px 8px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 6px 24px rgb(0 0 0 / .14); font-size: 13px; }
.peek-head { display: flex; gap: 8px; align-items: flex-start; }
.peek-titles { flex: 1; min-width: 0; display: grid; }
.peek-titles strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek-sub { color: var(--muted); font-size: 11px; }
.peek-body p { margin: 4px 4px 0 0; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.peek-body p.mono { word-break: break-all; }
#peek-info { color: var(--accent); flex: none; }

/* Modal für Details und Drift */
.modal { width: min(560px, calc(100% - 32px)); max-height: min(80vh, 760px); padding: 0; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: 0 12px 48px rgb(0 0 0 / .25); overflow: hidden; }
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgb(0 0 0 / .25); }
.modal-body { overflow: auto; padding: 16px 18px 24px; min-height: 0; }
.modal-body > h2 { font-family: var(--font-heading); font-size: 17px; margin: 0 0 8px; padding-right: 32px; }
.close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; z-index: 1; }
.close:focus:not(:focus-visible) { outline: none; }
.close:hover { background: var(--surface-2); color: var(--text); }
.hint { color: var(--muted); }

/* Detailpanel */
.d-head { padding-right: 32px; }
.d-head h2 { font-family: var(--font-heading); font-size: 17px; margin: 0 0 2px; word-break: break-word; }
.d-head .sub { color: var(--muted); font-size: 12px; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.modal h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
.itf { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; }
.dir { font-size: 11px; padding: 0 6px; border-radius: 4px; align-self: start; margin-top: 2px; }
.dir.provides { background: var(--accent-soft); color: var(--accent); }
.dir.consumes { background: var(--info-soft); color: var(--info); }
.itf .proto { color: var(--muted); font-size: 12px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.evidence { font-size: 12px; color: var(--muted); word-break: break-word; }

/* Driftliste */
.drift-item { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--info); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; }
.drift-item.warning { border-left-color: var(--warn); }
.drift-item:hover { border-color: var(--accent); }
.drift-item .t { font-weight: 600; font-size: 13px; }
.drift-item .n { color: var(--muted); font-size: 12px; word-break: break-all; }
.warn-item { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }

@media (max-width: 640px) {
  .hud-top { top: 8px; left: 8px; right: 8px; }
  .meta { display: none; }
  .seg button { padding: 4px 6px; }
  .popover { top: 48px; right: 8px; width: calc(100% - 16px); }
  .legend { display: none; }
  /* Bottom-Sheet statt Mitte */
  .modal { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 85vh; border-radius: 14px 14px 0 0; border-bottom: 0; }
}
