:root {
  --color-primary: #4F46E5;
  --color-secondary: #7C3AED;
  --color-accent: #06B6D4;
  --color-cta: #F97316;
  --color-bg: #FAFBFC;
  --color-text: #0F172A;
  --color-muted: #64748B;
  --color-pm: #6366F1;
  --color-ui: #8B5CF6;
  --color-backend: #0EA5E9;
  --color-cross: #F59E0B;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.06);
  --shadow-glass-hover: 0 12px 40px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  overflow-x: hidden;
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-flow {
  background: linear-gradient(-45deg, #EEF2FF, #E0E7FF, #ECFEFF, #F0F9FF, #FDF4FF, #EEF2FF);
  background-size: 400% 400%;
  animation: gradientFlow 20s ease infinite;
}

@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -50px) scale(1.1); }
  50% { transform: translate(-20px, 20px) scale(0.9); }
  75% { transform: translate(20px, 40px) scale(1.05); }
}

.animate-blob {
  animation: blob 8s ease-in-out infinite;
}

.animation-delay-2000 { animation-delay: 2s; }
.animation-delay-3000 { animation-delay: 3s; }
.animation-delay-4000 { animation-delay: 4s; }
.animation-delay-6000 { animation-delay: 6s; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}

.active-view {
  background: white;
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.active-domain {
  opacity: 1;
}

.domain-toggle:not(.active-domain) {
  opacity: 0.4;
  background: white;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  visibility: hidden;
}

.detail-modal.detail-modal-open {
  pointer-events: auto;
  visibility: visible;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(248, 250, 252, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.detail-modal-open .detail-modal-backdrop {
  opacity: 1;
}

.detail-modal-card {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.1),
    0 4px 6px -1px rgba(0, 0, 0, 0.04),
    0 12px 24px -4px rgba(0, 0, 0, 0.06),
    0 20px 48px -8px rgba(99, 102, 241, 0.08);
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow-y: auto;
  transform: scale(0.85) translateY(-8px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, top 0.3s ease, left 0.3s ease;
  pointer-events: auto;
}

.detail-modal-open .detail-modal-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.detail-modal-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--card-accent, #6366F1), transparent);
  border-radius: 1px;
  opacity: 0.6;
}

.detail-modal-card::-webkit-scrollbar {
  width: 4px;
}

.detail-modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.detail-modal-card::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 2px;
}

.detail-modal-card::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

.active-tab {
  transform: none;
}

.domain-tab:not(.active-tab):hover {
  transform: translateY(-1px);
}

.module-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  transition: width 0.25s ease;
}

.module-card:hover::before {
  width: 6px;
}

.module-card[data-domain="pm"]::before { background: var(--color-pm); }
.module-card[data-domain="ui"]::before { background: var(--color-ui); }
.module-card[data-domain="backend"]::before { background: var(--color-backend); }
.module-card[data-domain="cross"]::before { background: var(--color-cross); }

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glass-hover);
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.9);
}

.module-card .skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.module-card .skill-tag:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.module-card .orchestrator-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1.5px dashed;
  transition: all 0.2s ease;
}

.module-card .orchestrator-tag:hover {
  transform: translateY(-1px);
}

#graph-svg .node {
  cursor: pointer;
}

#graph-svg .node-circle {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#graph-svg .node-glow {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#graph-svg .node-label {
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  pointer-events: none;
  user-select: none;
  transition: all 0.2s ease;
}

#graph-svg .link-line {
  transition: stroke-opacity 0.3s ease;
}

#graph-svg .contract-path {
  transition: stroke-opacity 0.3s ease;
}

#graph-svg .particles circle {
  pointer-events: none;
}

#sankey-svg .sankey-node rect {
  cursor: pointer;
  transition: all 0.2s ease;
  rx: 6;
}

#sankey-svg .sankey-node rect:hover {
  filter: brightness(1.1);
  rx: 6;
}

#sankey-svg .sankey-link {
  fill: none;
  stroke-opacity: 0.35;
  transition: stroke-opacity 0.25s ease;
}

#sankey-svg .sankey-link:hover {
  stroke-opacity: 0.65;
}

#sankey-svg .sankey-node text {
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  font-size: 12px;
}

.count-up {
  font-variant-numeric: tabular-nums;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.fade-in-up:nth-child(1) { animation-delay: 0ms; }
.fade-in-up:nth-child(2) { animation-delay: 60ms; }
.fade-in-up:nth-child(3) { animation-delay: 120ms; }
.fade-in-up:nth-child(4) { animation-delay: 180ms; }
.fade-in-up:nth-child(5) { animation-delay: 240ms; }
.fade-in-up:nth-child(6) { animation-delay: 300ms; }

.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  border-radius: 1px;
  transition: all 0.2s ease;
  transform: translateX(-50%);
}

.nav-link:hover::after {
  width: 60%;
}

.nav-link[href="#graph"]::after { background: var(--color-primary); }
.nav-link[href="#sankey"]::after { background: var(--color-secondary); }
.nav-link[href="#modules"]::after { background: var(--color-accent); }

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

::selection {
  background: rgba(79, 70, 229, 0.15);
  color: var(--color-primary);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .gradient-flow {
    animation: none;
  }
  .animate-blob {
    animation: none;
  }
  .animate-bounce {
    animation: none;
  }
  .stat-card::after {
    animation: none;
  }
}

@media (max-width: 375px) {
  .stat-card {
    padding: 12px;
  }
  .stat-card .font-sora {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  #graph-container {
    height: 400px !important;
  }
  #sankey-container {
    height: 350px !important;
  }
  .domain-tab {
    padding: 6px 12px;
    font-size: 12px;
  }
}

@media (min-width: 1024px) and (max-width: 1440px) {
  #graph-container {
    height: 550px;
  }
}
