:root {
  color-scheme: light;
  --ink: #15211d;
  --muted: #5a6a65;
  --line: #c7d7d2;
  --surface: #ffffff;
  --surface-soft: #f1f7f4;
  --surface-warm: #fff3df;
  --paper: #fbfcf9;
  --green: #1f6f5b;
  --green-dark: #0f4538;
  --ochre: #be7327;
  --rust: #af482d;
  --set-a: #dcefe7;
  --set-b: #eef5df;
  --set-c: #e5f2eb;
  --set-a-line: #6fa38e;
  --set-b-line: #9bae72;
  --set-c-line: #6c9d83;
  --shadow: 0 18px 46px rgba(21, 33, 29, 0.16);
  --glass: rgba(255, 255, 255, 0.9);
  --glass-strong: rgba(255, 255, 255, 0.97);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 16% 12%, rgba(31, 111, 91, 0.1), transparent 34%),
    radial-gradient(circle at 86% 92%, rgba(190, 115, 39, 0.08), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell,
.workspace {
  width: 100%;
  height: 100%;
}

.workspace {
  position: relative;
  overflow: hidden;
}

.venn-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(31, 111, 91, 0.08), transparent 32%),
    radial-gradient(circle at 78% 72%, rgba(190, 115, 39, 0.06), transparent 30%),
    linear-gradient(rgba(15, 69, 56, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 69, 56, 0.045) 1px, transparent 1px),
    #ffffff;
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

.diagram-viewport {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.diagram-viewport.is-panning {
  cursor: grabbing;
}

.diagram-canvas {
  --left-clearance: clamp(380px, 29vw, 450px);
  position: absolute;
  top: 50%;
  left: calc(var(--left-clearance) + ((100vw - var(--left-clearance)) / 2));
  width: clamp(760px, calc(100vw - var(--left-clearance) - 48px), 1180px);
  aspect-ratio: 100 / 86;
  max-height: calc(100dvh - 56px);
  transform: translate(-50%, -50%);
  transform-origin: center;
  overflow: visible;
}

.diagram-canvas::before {
  content: "";
  position: absolute;
  inset: 9% 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 111, 91, 0.08), rgba(31, 111, 91, 0));
  filter: blur(18px);
  pointer-events: none;
}

.diagram-pan,
.diagram-zoom {
  position: absolute;
  inset: 0;
  overflow: visible;
  transform-origin: center;
}

.diagram-pan {
  --pan-x: 0px;
  --pan-y: 0px;
  transform: translate3d(var(--pan-x), var(--pan-y), 0);
  will-change: transform;
}

.diagram-zoom {
  --view-scale: 1;
  --node-counter-scale: 1;
  transform: scale(var(--view-scale));
  will-change: transform;
}

.venn-svg {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.set-circle {
  fill-opacity: 0.58;
  stroke-width: 0.42;
  mix-blend-mode: multiply;
}

.set-a {
  fill: var(--set-a);
  stroke: var(--set-a-line);
}

.set-b {
  fill: var(--set-b);
  stroke: var(--set-b-line);
}

.set-c {
  fill: var(--set-c);
  stroke: var(--set-c-line);
}

.set-label {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 3.2px;
  font-weight: 800;
  fill: rgba(15, 69, 56, 0.36);
  letter-spacing: 0;
  text-anchor: middle;
  pointer-events: none;
  text-rendering: geometricPrecision;
}

.label-c {
  font-size: 3.05px;
}

.nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.stakeholder-node {
  --x: 50%;
  --y: 50%;
  --set-color: var(--green);
  --node-emphasis-scale: 1;
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  display: grid;
  width: calc(var(--node-width, 68px) * var(--node-screen-scale, 1));
  height: calc(var(--node-height, 54px) * var(--node-screen-scale, 1));
  place-items: center;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transform: translate(-50%, -50%) scale(var(--node-counter-scale)) scale(var(--node-emphasis-scale));
  transition: opacity 160ms ease, transform 160ms ease, filter 160ms ease;
  will-change: transform;
}

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

.stakeholder-node.selected {
  z-index: 24;
  outline: none;
  --node-emphasis-scale: 1.08;
  filter: drop-shadow(0 10px 12px rgba(21, 33, 29, 0.2));
}

.stakeholder-node:hover,
.stakeholder-node:focus-visible {
  z-index: 42;
  outline: none;
  --node-emphasis-scale: 1.1;
  filter: drop-shadow(0 12px 14px rgba(21, 33, 29, 0.22));
}

.stakeholder-node.selected::before {
  display: none;
}

.stakeholder-node.dimmed {
  opacity: 0.2;
  filter: grayscale(0.35);
}

.node-media {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.node-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: normal;
  filter: drop-shadow(0 4px 7px rgba(21, 33, 29, 0.16));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.node-media.fallback-initials {
  background: transparent;
  color: var(--green-dark);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.86);
}

.node-name {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 30;
  display: none;
  width: max-content;
  max-width: 150px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-strong);
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.12);
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.14;
  overflow-wrap: anywhere;
  pointer-events: none;
  text-align: center;
  transform: translateX(-50%);
}

.stakeholder-node.selected .node-name,
.stakeholder-node:hover .node-name,
.stakeholder-node:focus-visible .node-name {
  display: block;
}

.stakeholder-node:hover .node-name,
.stakeholder-node:focus-visible .node-name {
  z-index: 60;
}

.sidebar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 600;
  display: flex;
  width: min(420px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  flex-direction: column;
  gap: 14px;
  overflow: auto;
  border: 1px solid rgba(14, 58, 48, 0.22);
  border-radius: 10px;
  padding: 14px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header {
  width: 100%;
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  color: var(--green-dark);
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.55rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  color: var(--green-dark);
  font-size: 0.95rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 4px;
  color: var(--green-dark);
  font-size: 1rem;
  line-height: 1.2;
}

.intro-text {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
}

.toolbar {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--green);
  color: var(--green-dark);
  outline: none;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.82);
}

.stat-value {
  display: block;
  color: var(--green-dark);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.25;
}

.control-section {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.search-shell {
  position: relative;
}

.search-shell svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px 9px 36px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.search-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 91, 0.14);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mini-count {
  display: inline-grid;
  min-width: 32px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-warm);
  color: #7a3e12;
  font-size: 0.77rem;
  font-weight: 800;
}

.filter-buttons {
  display: grid;
  gap: 8px;
}

.filter-chip {
  position: relative;
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.filter-chip::after {
  content: attr(data-count);
  display: inline-grid;
  min-width: 24px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  border-color: var(--green);
  background: #edf7f3;
  outline: none;
}

.filter-chip.active {
  border-color: var(--green);
  background: #eaf6f1;
  color: var(--green-dark);
  transform: translateX(2px);
}

.filter-chip.active::after {
  background: var(--green);
  color: #fff;
}

.detail-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 700;
  display: block;
  width: min(460px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid rgba(14, 58, 48, 0.24);
  border-radius: 10px;
  padding: 14px;
  background: var(--glass-strong);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  animation: detail-in 180ms ease both;
}

.detail-panel.is-hidden,
.workspace.detail-is-hidden .detail-panel {
  display: none;
}

.detail-close-button {
  position: sticky;
  top: 0;
  float: right;
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

.detail-close-button:hover,
.detail-close-button:focus-visible {
  border-color: var(--green);
  color: var(--green-dark);
  outline: none;
}

.detail-header {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
  padding-right: 38px;
}

.detail-header h2 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.25rem;
  line-height: 1.08;
}

.detail-media {
  display: grid;
  width: 72px;
  height: 56px;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--green-dark);
  font-size: 1.1rem;
  font-weight: 900;
  overflow: hidden;
}

.detail-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: normal;
  filter: drop-shadow(0 6px 10px rgba(21, 33, 29, 0.16));
}

.detail-type {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.set-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.set-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f5;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 800;
}

.set-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--green);
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.86);
}

.resource-link {
  margin-top: 10px;
}

.detail-section h3 {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.detail-section p {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.45;
}

.detail-functions {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.detail-functions li {
  position: relative;
  padding-left: 15px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
}

.detail-functions li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.resource-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green-dark);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 800;
}

.resource-link:hover {
  border-color: var(--green);
  background: #edf7f3;
}

.map-status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 500;
  max-width: min(360px, calc(100% - 28px));
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(31, 41, 51, 0.14);
  font-size: 0.82rem;
  font-weight: 800;
}

.map-status.is-hidden {
  display: none;
}

@keyframes detail-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1180px) {
  .diagram-canvas {
    --left-clearance: clamp(430px, 42vw, 460px);
    width: clamp(520px, calc(100vw - var(--left-clearance) - 24px), 760px);
  }
}

@media (max-width: 900px) {
  .sidebar {
    right: 10px;
    bottom: 10px;
    left: 10px;
    top: auto;
    width: auto;
    max-height: 43dvh;
    padding: 12px;
    gap: 10px;
  }

  .panel-title-row {
    align-items: flex-start;
  }

  .stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .diagram-canvas {
    top: 26dvh;
    left: 50%;
    width: min(610px, 100vw);
    height: auto;
    max-height: none;
  }

  .detail-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 58dvh;
    padding: 12px;
  }

  .map-status {
    top: 10px;
    left: 10px;
    bottom: auto;
    max-width: calc(100% - 20px);
  }

  .stakeholder-node {
    --node-screen-scale: 0.92;
  }

  .node-logo {
    width: 100%;
    height: 100%;
  }

  .node-name {
    max-width: 128px;
    font-size: 0.64rem;
  }

  h1 {
    font-size: 1.35rem;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .detail-panel {
    border-radius: 10px;
  }

  .sidebar {
    max-height: 45dvh;
  }

  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .panel-title-row {
    flex-wrap: wrap;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .filter-chip {
    min-height: 34px;
    font-size: 0.76rem;
  }

  .diagram-canvas {
    top: 26dvh;
    left: 43.5%;
    width: min(600px, 88vw);
  }

  .stakeholder-node {
    --node-screen-scale: 0.82;
  }

  .node-logo {
    width: 100%;
    height: 100%;
  }

  .node-name {
    max-width: 112px;
    padding: 4px 6px;
  }

  .detail-header {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }

  .detail-media {
    width: 58px;
    height: 46px;
  }
}
