.doc-mapping {
  position: relative;
  width: 100%;
  height: 100%;
  block-size: 100%;
  min-height: 420px;
  margin: 0;
  background: #0b1020;
  color: #f5f5f5;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.doc-mapping.theme-light {
  background: #fbf9f6;
  color: #0f172a;
}

.doc-mapping header {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 12;
  background: rgba(12, 18, 36, 0.9);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  max-width: calc(100% - 32px);
  box-sizing: border-box;
}

.doc-mapping.theme-light header {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.doc-mapping header h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: #f5f5f5;
}

.doc-mapping header p {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
  color: rgba(245, 245, 245, 0.85);
}

.doc-mapping.theme-light header h1 {
  color: #0f172a;
}

.doc-mapping.theme-light header p {
  color: rgba(15, 23, 42, 0.75);
}

.doc-mapping .legend {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 13px;
}

.doc-mapping .legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-mapping .legend-color {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.doc-mapping.theme-light .legend-color {
  border-color: rgba(15, 23, 42, 0.25);
}

.doc-mapping .controls {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  width: 100%;
}

.doc-mapping .controls label {
  opacity: 0.85;
}

.doc-mapping .controls select {
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  padding: 2px 6px;
  font-size: 13px;
  outline: none;
  flex: 1 1 220px;
  min-width: 0;
}

.doc-mapping.theme-light .controls select {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.2);
}

.doc-mapping .controls select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.5);
}

.doc-mapping .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7ff;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}

.doc-mapping .theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc-mapping .theme-toggle .icon-moon {
  display: none;
}

.doc-mapping.theme-light .theme-toggle {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

.doc-mapping.theme-light .theme-toggle .icon-sun {
  display: none;
}

.doc-mapping.theme-light .theme-toggle .icon-moon {
  display: inline;
}

.doc-mapping .theme-switch {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 18, 36, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.doc-mapping .theme-switch {
  display: none;
}

.doc-mapping .header-toggle {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 13;
  min-width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7ff;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
}

.doc-mapping .header-toggle-label {
  font-weight: 600;
  font-size: 12px;
}

.doc-mapping .header-toggle span {
  display: inline-flex;
  align-items: center;
}

.doc-mapping .header-toggle:hover {
  background: rgba(15, 23, 42, 0.9);
}

.doc-mapping .header-toggle:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.9);
  outline-offset: 2px;
}

.doc-mapping.theme-light .header-toggle {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

.doc-mapping.theme-light .header-toggle:hover {
  background: rgba(255, 255, 255, 1);
}

.doc-mapping .header-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 11;
}

.doc-mapping .theme-switch-label {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.8;
}

.doc-mapping .zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 12;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
}

.doc-mapping .zoom-button {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7ff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.doc-mapping .zoom-button:hover {
  background: rgba(15, 23, 42, 0.9);
}

.doc-mapping .zoom-button:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.9);
  outline-offset: 2px;
}

.doc-mapping.theme-light .zoom-button {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

.doc-mapping.theme-light .zoom-button:hover {
  background: rgba(255, 255, 255, 1);
}

.doc-mapping.theme-light .theme-switch {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}

.doc-mapping svg {
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.doc-mapping svg:active {
  cursor: grabbing;
}

.doc-mapping .link {
  fill: none;
  stroke: #e5e7ff;
  stroke-width: 1;
  stroke-opacity: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.doc-mapping.theme-light .link {
  stroke: #64748b;
}

.doc-mapping .node {
  stroke: #0b1020;
  stroke-width: 1.4;
}

.doc-mapping .node-toggle {
  font-size: 10px;
  fill: #ffffff;
  pointer-events: none;
  font-weight: 400;
}

.doc-mapping .label {
  font-size: 12px;
  fill: #f5f5f5;
  pointer-events: none;
  text-shadow: none;
}

.doc-mapping .resource-pill {
  pointer-events: auto;
  cursor: pointer;
}

.doc-mapping .resource-pill rect {
  stroke: rgba(148, 163, 184, 0.6);
  stroke-width: 1;
  rx: 10px !important;
  ry: 10px !important;
}

.doc-mapping .resource-pill text {
  font-size: 13px;
  fill: #111827;
  stroke: none;
}

.doc-mapping .resource-pill-right {
  pointer-events: auto;
  cursor: pointer;
}

.doc-mapping .resource-pill-right rect {
  stroke: none;
  stroke-width: 0;
  rx: 10px !important;
  ry: 10px !important;
}

.doc-mapping .resource-pill-right text {
  font-size: 13px;
  fill: #111827;
  stroke: none;
}

.doc-mapping .tooltip {
  position: absolute;
  padding: 6px 28px 6px 8px;
  background: rgba(9, 13, 30, 0.96);
  color: #f5f5f5;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  max-width: 260px;
  z-index: 20;
}

.doc-mapping .tooltip.is-pinned {
  pointer-events: auto;
}

.doc-mapping.theme-light .tooltip {
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.16);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.doc-mapping .tooltip-close {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f5f5;
  font-size: 16px;
  line-height: 22px;
  cursor: pointer;
  padding: 0;
}

.doc-mapping .tooltip-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.doc-mapping.theme-light .tooltip-close {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

.doc-mapping.theme-light .tooltip-close:hover {
  background: rgba(15, 23, 42, 0.16);
}

.doc-mapping .tooltip a {
  color: #e5e7ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(229, 231, 255, 0.4);
}

.doc-mapping .tooltip a:hover {
  border-bottom-color: rgba(229, 231, 255, 0.8);
}

.doc-mapping.theme-light .tooltip a {
  color: #1d4ed8;
  border-bottom-color: rgba(29, 78, 216, 0.35);
}

.doc-mapping.theme-light .tooltip a:hover {
  border-bottom-color: rgba(29, 78, 216, 0.7);
}

.doc-mapping .tooltip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.doc-mapping .tooltip-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .doc-mapping header {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: min(86%, 360px);
    max-width: none;
    border-radius: 0;
    padding: 56px 18px calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform 240ms ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    overflow-y: auto;
  }

  .doc-mapping.is-header-open header {
    transform: translateX(0);
  }

  .doc-mapping .header-toggle {
    display: inline-flex;
  }

  .doc-mapping.is-header-open .header-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .doc-mapping header h1 {
    font-size: 16px;
  }

  .doc-mapping header p {
    font-size: 14px;
  }

  .doc-mapping .legend {
    font-size: 14px;
  }

  .doc-mapping .controls {
    font-size: 14px;
    gap: 10px 14px;
  }

  .doc-mapping .controls select {
    font-size: 14px;
    padding: 8px 12px;
    flex: 1 1 100%;
    width: 100%;
  }

  .doc-mapping .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .doc-mapping .theme-toggle svg {
    width: 20px;
    height: 20px;
  }

  .doc-mapping .theme-switch {
    top: auto;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
  }

  .doc-mapping .theme-switch-label {
    font-size: 13px;
  }

  .doc-mapping .zoom-controls {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

}
