:root {
  color-scheme: dark;
  --mapon-bg: #040912;
  --mapon-panel: rgba(7, 17, 32, 0.72);
  --mapon-line: rgba(32, 211, 238, 0.55);
  --mapon-text: #eef7ff;
  --mapon-muted: #91a4bb;
  --mapon-cyan: #16d3e5;
  --mapon-core: #67e8f9;
  --mapon-center: #f8fafc;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--mapon-bg);
  color: var(--mapon-text);
  font-family:
    Inter,
    Pretendard,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

a,
button {
  font: inherit;
}

.mapon-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 25%, rgba(18, 148, 169, 0.2), transparent 28rem),
    radial-gradient(circle at 20% 72%, rgba(74, 222, 128, 0.08), transparent 26rem),
    #040912;
}

.mapon-stage {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.mapon-stage.is-panning {
  cursor: grabbing;
}

.mapon-map-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.mapon-map-background::before,
.mapon-map-background::after {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 18vw;
  min-width: 180px;
  content: "";
}

.mapon-map-background::before {
  left: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(35, 108, 128, 0.08), transparent 34rem),
    linear-gradient(90deg, rgba(3, 8, 16, 0.46), rgba(3, 8, 16, 0));
}

.mapon-map-background::after {
  right: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(35, 108, 128, 0.08), transparent 34rem),
    linear-gradient(270deg, rgba(3, 8, 16, 0.46), rgba(3, 8, 16, 0));
}

.mapon-map-strip {
  position: absolute;
  top: -10vh;
  top: -10dvh;
  left: 50%;
  display: flex;
  height: 112vh;
  height: 112dvh;
  transform: translateX(-50%);
}

.mapon-map-strip img {
  display: block;
  flex: 0 0 auto;
  width: auto;
  height: 112vh;
  height: 112dvh;
  max-width: none;
  opacity: 0.53;
  filter: saturate(0.72) contrast(0.92) brightness(0.85);
  user-select: none;
}

.mapon-viewport {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: var(--mapon-stage-width, 100vw);
  height: var(--mapon-stage-height, 100dvh);
  transform-origin: 0 0;
  will-change: transform;
}

.mapon-lines,
.mapon-nodes {
  position: absolute;
  inset: 0;
  width: var(--mapon-stage-width, 100vw);
  height: var(--mapon-stage-height, 100dvh);
}

.mapon-lines {
  overflow: visible;
  pointer-events: none;
}

.mapon-lines line,
.mapon-lines path {
  fill: none;
  vector-effect: non-scaling-stroke;
}

.mapon-line-user {
  stroke: rgba(180, 210, 226, 0.36);
  stroke-width: 1.5;
  stroke-dasharray: 4 7;
}

.mapon-line-core {
  stroke: rgba(43, 224, 240, 0.84);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.58));
  stroke-dasharray: 14 16;
  animation: maponFlow 2.8s linear infinite;
}

.mapon-line-category {
  stroke: rgba(93, 204, 219, 0.48);
  stroke-width: 1.3;
}

.mapon-line-ai {
  stroke: var(--line-color, rgba(125, 211, 252, 0.5));
  stroke-width: 1.1;
  opacity: 0.76;
}

@keyframes maponFlow {
  to {
    stroke-dashoffset: -60;
  }
}

.mapon-node {
  position: absolute;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(10, 20, 35, 0.86);
  color: #ffffff;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 18px rgba(22, 211, 229, 0.22);
  transform: translate(-50%, -50%);
  user-select: none;
  cursor: grab;
  will-change: transform;
}

.mapon-node.is-dragging {
  z-index: 20;
  cursor: grabbing;
  filter: brightness(1.16);
}

.mapon-node.is-fixed {
  cursor: default;
}

.mapon-node span,
.mapon-node strong,
.mapon-node small {
  pointer-events: none;
}

.mapon-node-user {
  width: 24px;
  height: 24px;
  z-index: 12;
  border-color: rgba(226, 232, 240, 0.52);
  background: rgba(226, 232, 240, 0.16);
}

.mapon-node-user::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  box-shadow: 0 0 18px #e2e8f0;
}

.mapon-node-core {
  display: grid;
  width: var(--node-width, 132px);
  height: var(--node-height, 112px);
  padding: 12px 13px;
  z-index: 13;
  gap: 7px;
  border-radius: 10px;
  border-color: rgba(103, 232, 249, 0.5);
  background:
    linear-gradient(180deg, rgba(16, 37, 56, 0.92), rgba(5, 15, 27, 0.94)),
    rgba(6, 18, 30, 0.94);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.16),
    0 16px 34px rgba(0, 0, 0, 0.3),
    0 0 22px rgba(34, 211, 238, 0.18);
  place-items: stretch;
  transform-origin: 0 0;
}

.mapon-node-core .mapon-core-label,
.mapon-node-core strong {
  display: block;
  color: #dffbff;
  text-align: center;
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  line-height: 1;
}

.mapon-node-core .mapon-core-label {
  color: rgba(190, 242, 255, 0.92);
}

.mapon-core-rack {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(125, 211, 252, 0.2);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(15, 32, 51, 0.88), rgba(4, 12, 22, 0.9));
  box-shadow: inset 0 0 14px rgba(34, 211, 238, 0.08);
}

.mapon-core-rack i {
  position: relative;
  display: block;
  height: 9px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgba(34, 211, 238, 0.18), rgba(148, 163, 184, 0.12)),
    rgba(2, 9, 18, 0.84);
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.08);
}

.mapon-core-rack i::before,
.mapon-core-rack i::after {
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  content: "";
  transform: translateY(-50%);
}

.mapon-core-rack i::before {
  left: 7px;
  background: rgba(34, 211, 238, 0.88);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.58);
}

.mapon-core-rack i::after {
  right: 8px;
  background: rgba(148, 163, 184, 0.38);
}

.mapon-node-center {
  width: 64px;
  height: 64px;
  z-index: 14;
  border-color: rgba(255, 255, 255, 0.68);
  background:
    radial-gradient(circle, rgba(248, 250, 252, 0.33), transparent 48%),
    rgba(8, 21, 36, 0.92);
  grid-template-rows: 13px 28px 13px;
  align-content: center;
  justify-items: center;
  gap: 0;
}

.mapon-node-center strong {
  width: 48px;
  text-align: center;
  font-size: 0.46rem;
  line-height: 1.05;
  letter-spacing: 0.08em;
}

.mapon-node-center span {
  font-size: 0.62rem;
  font-weight: 950;
  line-height: 1;
}

.mapon-center-device {
  display: grid;
  place-items: center;
  width: 42px;
  height: 28px;
  color: rgba(226, 232, 240, 0.92);
  filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.42));
  pointer-events: none;
}

.mapon-center-device svg {
  display: block;
  width: 42px;
  height: 30px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mapon-node-category {
  width: var(--node-width, 49px);
  height: var(--node-height, 44px);
  z-index: 11;
  border-color: transparent;
  border-radius: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--category-icon-color, #ef4444) 24%, transparent), rgba(11, 15, 27, 0.82)),
    rgba(8, 15, 28, 0.82);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--category-icon-color, #ef4444) 48%, rgba(255, 255, 255, 0.1)),
    0 0 12px color-mix(in srgb, var(--category-icon-color, #ef4444) 22%, transparent),
    inset 0 0 14px rgba(255, 255, 255, 0.035);
  clip-path: polygon(24% 0, 76% 0, 100% 50%, 76% 100%, 24% 100%, 0 50%);
}

.mapon-node-category span {
  width: 32px;
  color: #ecfeff;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.mapon-node-category .mapon-category-icon-label {
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.16);
}

.mapon-node-ai {
  width: 32px;
  height: 32px;
  z-index: 12;
  overflow: hidden;
  place-items: center;
  border-color: color-mix(in srgb, var(--node-color, #22d3ee) 62%, rgba(255, 255, 255, 0.2));
  background: rgba(8, 17, 30, 0.92);
  line-height: 0;
}

.mapon-ai-favicon-shell {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d9e6f3;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: none;
  line-height: 0;
  pointer-events: none;
}

.mapon-ai-icon-frame {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  grid-area: 1 / 1;
}

.mapon-ai-icon-frame img {
  display: block;
  width: calc(100% * var(--mapon-icon-scale, 0.76));
  height: calc(100% * var(--mapon-icon-scale, 0.76));
  transform: translate(var(--mapon-icon-x, 0px), var(--mapon-icon-y, 0px));
  border-radius: 0;
  object-fit: contain;
  object-position: center;
}

.mapon-ai-icon-frame:has(img[hidden]) {
  display: none;
}

.mapon-ai-icon-frame img[hidden] {
  display: none;
}

.mapon-ai-favicon-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #14b8a6, #38bdf8);
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1;
  grid-area: 1 / 1;
}

.mapon-ai-icon-frame:has(img:not([hidden])) + .mapon-ai-favicon-fallback {
  display: none;
}

.mapon-node-more {
  width: 28px;
  height: 28px;
  z-index: 8;
  border-style: dashed;
  color: #dff8ff;
  font-size: 0.62rem;
  font-weight: 900;
}

.mapon-hud {
  position: absolute;
  z-index: 30;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: var(--mapon-panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(14px);
}

.mapon-hud-top {
  top: 18px;
  right: 18px;
  left: 18px;
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
}

.mapon-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--mapon-cyan);
  font-size: 1rem;
  font-weight: 950;
  text-decoration: none;
}

.mapon-brand img {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(22, 211, 229, 0.3);
}

.mapon-title {
  display: grid;
  gap: 2px;
  text-align: center;
}

.mapon-title span,
.mapon-panel-kicker {
  color: var(--mapon-cyan);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.mapon-title strong {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.mapon-status {
  min-width: 126px;
  color: var(--mapon-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: right;
}

body:not(.mapon-sample-mode) .mapon-status {
  color: rgba(190, 242, 255, 0.82);
}

.mapon-sample-mode .mapon-status {
  font-size: 0.68rem;
  opacity: 0.72;
}

.mapon-panel {
  position: absolute;
  z-index: 28;
  left: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(310px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(7, 17, 32, 0.7);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.mapon-panel strong {
  display: block;
  margin-top: 5px;
  font-size: 1.06rem;
}

.mapon-panel dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 0;
}

.mapon-panel div {
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.mapon-panel dt {
  color: var(--mapon-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.mapon-panel dd {
  margin: 4px 0 0;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 950;
}

.mapon-controls {
  position: absolute;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 32;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(430px, calc(100vw - 350px));
}

.mapon-controls button,
.mapon-controls a {
  display: inline-flex;
  min-width: 38px;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 999px;
  background: rgba(9, 22, 37, 0.76);
  color: #eaffff;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.mapon-controls button:hover,
.mapon-controls a:hover,
.mapon-controls button:focus-visible,
.mapon-controls a:focus-visible {
  border-color: rgba(22, 211, 229, 0.58);
  background: rgba(18, 148, 169, 0.26);
}

.mapon-toast {
  position: absolute;
  z-index: 50;
  top: 50%;
  left: 50%;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 18px;
  border: 1px solid rgba(22, 211, 229, 0.34);
  border-radius: 999px;
  background: rgba(5, 12, 22, 0.86);
  color: #eaffff;
  font-size: 0.92rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 34px rgba(22, 211, 229, 0.2);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
}

@media (max-width: 760px) {
  .mapon-hud-top {
    top: 10px;
    right: 10px;
    left: 10px;
    min-height: 56px;
    padding: 10px;
  }

  .mapon-title {
    display: none;
  }

  .mapon-status {
    min-width: 0;
    font-size: 0.68rem;
  }

  .mapon-panel {
    right: 10px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    padding: 12px;
  }

  .mapon-panel dl {
    margin-top: 10px;
  }

  .mapon-controls {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    justify-content: center;
    max-width: none;
  }

  .mapon-controls button,
  .mapon-controls a {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }
}

@media (max-width: 1040px) and (min-width: 761px) {
  .mapon-panel {
    width: min(280px, calc(50vw - 28px));
  }

  .mapon-controls {
    max-width: min(390px, calc(50vw - 28px));
  }
}
