/* ===== Design Tokens ===== */
:root {
  /* Deep Navy Blue */
  --navy-900: #060E1A;
  --navy-800: #0A1830;
  --navy-700: #0D2140;
  --navy-600: #102A52;
  --navy-500: #153563;

  /* Jabil Dark Blue Accent */
  --blue-600: #001A2C;
  --blue-500: #002B49;
  /* rgb(0, 43, 73) Brand Color */
  --blue-400: #004270;
  --blue-300: #005999;
  --blue-100: #CCE1F0;
  --blue-50: #E5F0F7;

  /* Neutrals */
  --white: #FFFFFF;
  --gray-50: #F7F8FA;
  --gray-100: #EEF0F4;
  --gray-200: #DDE1E8;
  --gray-300: #C5CAD4;
  --gray-400: #9BA3B0;
  --gray-500: #6B7482;
  --gray-600: #4B5463;
  --gray-700: #333B47;
  --gray-800: #1E232B;
  --gray-900: #101317;

  /* Semantic */
  --bg-page: var(--gray-50);
  --bg-surface: var(--white);
  --bg-sidebar: var(--navy-900);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-400);
  --border-default: var(--gray-200);
  --border-subtle: var(--gray-100);
  --accent: var(--blue-500);
  --accent-hover: var(--blue-600);
  --accent-light: var(--blue-50);

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-collapsed: 56px;
  --topbar-h: 52px;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Base ===== */
body {
  font-family: 'Inter', 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Ambient Background (Glassmorphism backdrop) ===== */
.ambient-background {
  position: absolute;
  inset: -50%;
  z-index: 0;
  /* Jabil Dark Blue ambient glow */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(0, 43, 73, 0.25) 0%, transparent 55%),
    radial-gradient(circle at 80% 20%, rgba(0, 89, 153, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 20% 80%, rgba(0, 43, 73, 0.2) 0%, transparent 55%);
  animation: ambientFloat 20s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ambientFloat {
  0% {
    transform: rotate(0deg) scale(1);
  }

  100% {
    transform: rotate(15deg) scale(1.1);
  }
}

/* ===== Sidebar ===== */
.sidebar {
  position: relative;
  z-index: 10;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  /* Glassmorphism Sidebar with rgb(0, 43, 73) base */
  background: rgba(0, 43, 73, 0.85);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 1px 0 0 rgba(0, 0, 0, .08), 8px 0 32px rgba(0, 0, 0, .15);

  display: flex;
  flex-direction: column;
  transition: width .28s cubic-bezier(.4, 0, .2, 1), min-width .28s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

/* ---- text fade transition (shared) ---- */
.sidebar-title,
.sidebar-subtitle,
.nav-section-label,
.nav-item .nav-label,
.nav-item .nav-shortcut,
.toggle-label {
  transition: opacity .16s ease;
}

/* ---- Sidebar Header ---- */
.sidebar-header {
  padding: 24px 0 20px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.sidebar-logo {
  width: 34px;
  min-width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 8px;
}

.sidebar-logo svg {
  width: 20px;
  height: 20px;
  color: var(--blue-500);
}

/* Hub Logo Animations */
.hub-orbit {
  transform-origin: 12px 12px;
  animation: hubSpin 15s linear infinite;
}
.hub-core {
  transform-origin: 12px 12px;
  animation: hubPulse 2s ease-in-out infinite alternate;
}
@keyframes hubSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes hubPulse {
  0% { transform: scale(0.85); stroke-width: 3px; }
  100% { transform: scale(1.15); stroke-width: 1.5px; }
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-title {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.01em;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255, 255, 255, .35);
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1.2;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-subtitle {
  opacity: 0;
  pointer-events: none;
}

/* ---- Nav Section ---- */
.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, .3);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 12px 0 8px 11px;
  white-space: nowrap;
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
  pointer-events: none;
}

/* Nav Item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 12px 11px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .6);
  cursor: pointer;
  font-family: 'Inter', 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  /* Spring physics transition */
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.nav-item:hover {
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .08);
  /* Hover scale up slightly */
  transform: translateX(4px) scale(1.02);
}

.nav-item:active {
  /* Active scale down slightly */
  transform: translateX(2px) scale(0.98);
}

.nav-item:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: -2px;
}

.nav-item.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.nav-item.active::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: shimmerSweep 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes shimmerSweep {
  0% { left: -100%; }
  40% { left: 200%; }
  100% { left: 200%; }
}

.nav-item.active:hover {
  /* Prevent shifting when already active */
  transform: none;
}

.nav-item .nav-icon {
  width: 30px;
  min-width: 30px;
  height: 30px;
  margin: 0 2px; /* Total width 34px (2 + 30 + 2) to match main logo alignment */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: transparent;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-item .nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Dynamic icon images for sidebar */
.nav-item .nav-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.sidebar.collapsed .nav-item:hover {
  /* Disable transform in collapsed mode to keep icon pinned */
  transform: none;
}

.sidebar.collapsed .nav-item .nav-label,
.sidebar.collapsed .nav-item .nav-shortcut {
  opacity: 0;
  pointer-events: none;
}

.nav-shortcut {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, .2);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .05);
}

/* ---- Empty State ---- */
.nav-empty {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  padding: 24px 16px;
  line-height: 1.6;
}

.welcome-empty {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 14px;
  color: var(--gray-400);
  text-align: center;
  padding: 40px 24px;
  line-height: 1.6;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  padding: 8px 0 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.nav-add-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 10px 11px;
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .6);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 8px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.nav-add-btn:hover {
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .08);
  transform: translateX(4px) scale(1.02);
}

.nav-add-btn:active {
  transform: translateX(2px) scale(0.98);
}

.nav-add-btn:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: -2px;
}

.nav-add-btn svg {
  width: 30px;
  min-width: 30px;
  height: 30px;
  margin: 0 2px;
  padding: 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .08);
}

.sidebar.collapsed .nav-add-btn {
  padding: 8px;
  min-width: 40px;
  justify-content: center;
}

.sidebar.collapsed .nav-add-btn .nav-add-label {
  display: none;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 10px 11px;
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, .45);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 8px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.toggle-btn:hover {
  color: rgba(255, 255, 255, .8);
  background: rgba(255, 255, 255, .04);
}

.toggle-btn:active {
  transform: scale(0.96);
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: -2px;
}

.toggle-arrows {
  width: 34px;
  min-width: 34px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  transition: transform .3s ease;
  opacity: .7;
}

.sidebar.collapsed .toggle-arrows {
  transform: rotate(180deg);
}

.sidebar.collapsed .toggle-label {
  opacity: 0;
  pointer-events: none;
}

/* ===== Main ===== */
.main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
  /* let ambient background show through */
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 20px;
  /* Glassmorphism Topbar */
  background: rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status indicator */
.tool-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00A9E0;
  animation: dotRipple 2.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

@keyframes dotRipple {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 169, 224, 0.6), 0 0 8px rgba(0, 169, 224, 0.8);
  }
  100% {
    box-shadow: 0 0 0 10px rgba(0, 169, 224, 0), 0 0 2px rgba(0, 169, 224, 0);
  }
}

.tool-name {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

.tool-desc {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-500);
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border-default);
}

.topbar-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all .2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.topbar-action svg {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar-action:hover {
  color: var(--gray-900);
  border-color: var(--gray-300);
  background: var(--gray-50);
  transform: scale(1.02);
}

#btnRefresh:hover svg {
  transform: rotate(180deg);
}

.topbar-action:active {
  transform: scale(0.98);
}

.topbar-action:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 1px;
}

.topbar-action.primary {
  background: var(--blue-500);
  color: var(--white);
  border-color: var(--blue-500);
  font-weight: 600;
}

.topbar-action.primary:hover {
  background: var(--blue-600);
  border-color: var(--blue-600);
}

/* ===== Iframe Container ===== */
.iframe-container {
  flex: 1;
  position: relative;
  /* Glassmorphism Container */
  background: transparent;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: none;
  position: absolute;
  inset: 0;
}

.iframe-container iframe.active {
  display: block;
  /* Premium enter animation */
  animation: iframeEnter 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes iframeEnter {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Welcome Page (Full-screen Overlay) ===== */
.welcome-page {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.8s ease;
}

/* Theme Backgrounds */
.welcome-page.theme-default { background: linear-gradient(135deg, #f8fafc 0%, #e8f0fe 50%, #f0f4ff 100%); }
.welcome-page.theme-aurora { background: #040914; }
.welcome-page.theme-network { background: #060e1a; }

.welcome-page.hidden {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

/* -- Theme Switcher -- */
.welcome-theme-switcher {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 110;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 6px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.welcome-page.theme-aurora .welcome-theme-switcher,
.welcome-page.theme-network .welcome-theme-switcher {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--gray-900);
  opacity: 0.6;
}

.welcome-page.theme-aurora .theme-btn,
.welcome-page.theme-network .theme-btn {
  color: rgba(255, 255, 255, 0.7);
}

.theme-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.theme-btn.active {
  opacity: 1;
  background: var(--white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  color: var(--blue-500);
}

.welcome-page.theme-aurora .theme-btn.active,
.welcome-page.theme-network .theme-btn.active {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: #ffffff;
}

/* -- Background Layers -- */
.welcome-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-default, .bg-aurora, .bg-network {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s ease;
}

.theme-default .bg-default { opacity: 1; }
.theme-aurora .bg-aurora { opacity: 1; }
.theme-network .bg-network { opacity: 1; pointer-events: auto; }

/* -- Glowing Orb (Default) -- */
.welcome-orb {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 43, 73, 0.15) 0%, rgba(0, 89, 153, 0.08) 40%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: orbPulse 4s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes orbPulse {
  0% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.3; }
  100% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

/* -- Floating Particles -- */
.welcome-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.welcome-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--blue-500);
  opacity: 0;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    transform: translate(0, 0) scale(0.5);
    opacity: 0;
  }
  20% {
    opacity: 0.8;
  }
  50% {
    transform: translate(2vw, -3vh) scale(1.2);
    opacity: 0.5;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translate(-1vw, -6vh) scale(0.5);
    opacity: 0;
  }
}

/* -- Aurora Specifics -- */
.bg-aurora {
  filter: blur(80px);
}
.aurora-blob {
  position: absolute;
  /* Irregular shape makes rotation visible */
  border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  animation: auroraFloat 15s infinite alternate ease-in-out;
}
.blob-1 { width: 70vw; height: 70vw; background: rgba(0, 43, 73, 0.8); top: -30%; left: -10%; animation-duration: 18s; }
.blob-2 { width: 60vw; height: 60vw; background: rgba(0, 89, 153, 0.6); bottom: -20%; right: -10%; animation-duration: 15s; animation-direction: alternate-reverse; }
.blob-3 { width: 50vw; height: 50vw; background: rgba(0, 169, 224, 0.4); top: 20%; left: 30%; animation-duration: 22s; }
.blob-4 { width: 60vw; height: 60vw; background: rgba(82, 139, 255, 0.5); bottom: 10%; left: -20%; animation-duration: 20s; animation-direction: alternate-reverse; }

@keyframes auroraFloat {
  0% { 
    transform: translate(0, 0) scale(1) rotate(0deg); 
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  }
  33% {
    transform: translate(15vw, 10vh) scale(1.1) rotate(120deg); 
    border-radius: 60% 40% 30% 70% / 50% 60% 50% 40%;
  }
  66% {
    transform: translate(-10vw, 20vh) scale(0.9) rotate(240deg); 
    border-radius: 50% 50% 60% 40% / 60% 40% 70% 50%;
  }
  100% { 
    transform: translate(-15vw, -10vh) scale(1.05) rotate(360deg); 
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
  }
}

/* -- Network Specifics -- */
#networkCanvas { width: 100%; height: 100%; display: block; }

/* -- Theme Adaptations for Text & Cards (Dark Mode) -- */
.welcome-page.theme-aurora .welcome-greeting,
.welcome-page.theme-network .welcome-greeting,
.welcome-page.theme-aurora .welcome-subtitle,
.welcome-page.theme-network .welcome-subtitle,
.welcome-page.theme-aurora .welcome-footer,
.welcome-page.theme-network .welcome-footer {
  color: rgba(255, 255, 255, 0.7);
}

.welcome-page.theme-aurora .welcome-brand,
.welcome-page.theme-network .welcome-brand {
  background: linear-gradient(135deg, #ffffff 0%, #a5d8ff 50%, #ffffff 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
}

.welcome-page.theme-aurora .welcome-card,
.welcome-page.theme-network .welcome-card {
  background: rgba(10, 24, 48, 0.6);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.welcome-page.theme-aurora .welcome-card:hover,
.welcome-page.theme-network .welcome-card:hover {
  background: rgba(10, 24, 48, 0.85);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.welcome-page.theme-aurora .welcome-card-body h3,
.welcome-page.theme-network .welcome-card-body h3 {
  color: #ffffff;
}

.welcome-page.theme-aurora .welcome-card-body p,
.welcome-page.theme-network .welcome-card-body p {
  color: rgba(255, 255, 255, 0.6);
}

.welcome-page.theme-aurora .welcome-card-shortcut kbd,
.welcome-page.theme-network .welcome-card-shortcut kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
}

/* -- Welcome Content -- */
.welcome-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  padding: 40px;
  animation: welcomeFadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes welcomeFadeIn {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* -- Animated Logo -- */
.welcome-logo {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-logo-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
}

.welcome-logo-ring.ring-1 {
  width: 100%;
  height: 100%;
  border-color: rgba(0, 43, 73, 0.15);
  border-top-color: rgba(0, 89, 153, 0.6);
  animation: ringRotate 4s linear infinite;
}

.welcome-logo-ring.ring-2 {
  width: 85%;
  height: 85%;
  border-color: rgba(0, 43, 73, 0.08);
  border-right-color: rgba(0, 66, 112, 0.4);
  animation: ringRotate 6s linear infinite reverse;
}

.welcome-logo-ring.ring-3 {
  width: 70%;
  height: 70%;
  border-color: rgba(0, 43, 73, 0.05);
  border-bottom-color: rgba(0, 43, 73, 0.3);
  animation: ringRotate 8s linear infinite;
}

@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.welcome-logo-core {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
  border-radius: 14px;
  box-shadow:
    0 4px 24px rgba(0, 43, 73, 0.3),
    0 0 0 6px rgba(0, 43, 73, 0.06);
}

.welcome-logo-core svg {
  width: 30px;
  height: 30px;
  color: var(--white);
}

/* -- Welcome Text -- */
.welcome-text {
  text-align: center;
  animation: welcomeFadeIn 0.8s 0.15s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.welcome-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
}

.welcome-greeting {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-500);
  letter-spacing: 0.06em;
}

.welcome-brand {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-300) 50%, var(--blue-500) 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: brandShimmer 4s ease-in-out infinite;
}

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

.welcome-subtitle {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--gray-400);
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* -- Tool Cards -- */
.welcome-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  padding: 10px 0;
  animation: welcomeFadeIn 0.8s 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.welcome-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  width: 280px;
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(0, 43, 73, 0.08);
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  box-shadow:
    0 2px 8px rgba(0, 43, 73, 0.04),
    0 8px 32px rgba(0, 43, 73, 0.06);
}

.welcome-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(0, 43, 73, 0.18);
  box-shadow:
    0 8px 24px rgba(0, 43, 73, 0.1),
    0 24px 48px rgba(0, 43, 73, 0.12);
}

.welcome-card:active {
  transform: translateY(-2px) scale(0.99);
}

.welcome-card:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 2px;
}

/* Card Glow Effect */
.welcome-card-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(0, 89, 153, 0.08) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.welcome-card:hover .welcome-card-glow {
  opacity: 1;
}

.welcome-card-icon {
  width: 44px;
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.welcome-card:hover .welcome-card-icon {
  transform: scale(1.1) rotate(-3deg);
}

.welcome-card-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Dynamic icon images for welcome cards */
.welcome-card-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.welcome-card-body {
  flex: 1;
  min-width: 0;
}

.welcome-card-body h3 {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}

.welcome-card-body p {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 12px;
  color: var(--gray-400);
  line-height: 1.4;
}

.welcome-card-shortcut kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  padding: 3px 7px;
  border-radius: 5px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  white-space: nowrap;
}

.welcome-card-arrow {
  color: var(--gray-300);
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateX(-8px);
}

.welcome-card:hover .welcome-card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--blue-400);
}

/* -- Footer -- */
.welcome-footer {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 12px;
  color: var(--gray-300);
  letter-spacing: 0.02em;
  animation: welcomeFadeIn 0.8s 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* -- Staggered card entrance -- */
.welcome-card:nth-child(1) { animation: cardEnter 0.6s 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.welcome-card:nth-child(2) { animation: cardEnter 0.6s 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.welcome-card:nth-child(3) { animation: cardEnter 0.6s 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes cardEnter {
  0% { opacity: 0; transform: translateY(24px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Loading ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  opacity: 1;
  transition: opacity .3s ease;
  pointer-events: none;
  z-index: 5;
}

.loading-overlay.hidden {
  opacity: 0;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
    min-width: var(--sidebar-collapsed);
  }

  .sidebar-title,
  .sidebar-subtitle,
  .nav-section-label,
  .nav-item .nav-label,
  .nav-item .nav-shortcut,
  .toggle-label {
    opacity: 0;
    pointer-events: none;
  }

  .topbar {
    padding: 0 12px;
  }

  .tool-desc {
    display: none;
  }

  .iframe-container {
    margin: 0;
    border-radius: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
  }

  .welcome-cards {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .welcome-card {
    width: 100%;
    max-width: 320px;
  }

  .welcome-orb {
    width: 300px;
    height: 300px;
  }

  .welcome-brand {
    font-size: 32px;
  }

  .welcome-content {
    padding: 24px 16px;
    gap: 28px;
  }

  .welcome-logo {
    width: 90px;
    height: 90px;
  }

  .welcome-logo-core {
    width: 44px;
    height: 44px;
  }
}

/* ===== Management Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-container {
  position: relative;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  animation: modalEnter 0.3s ease;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid rgba(0, 43, 73, 0.08);
}

.modal-header h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--navy-800, #001a2e);
  margin: 0;
}

.modal-close-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 8px;
  color: var(--gray-500, #6b7280);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--navy-800, #001a2e);
}

.modal-body {
  padding: 16px 24px 24px;
  overflow-y: auto;
  flex: 1;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== Modal Content: Tool List ===== */
.modal-tool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-empty {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 14px;
  color: var(--gray-400);
  text-align: center;
  padding: 40px 24px;
  line-height: 1.6;
}

.modal-tool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 43, 73, 0.06);
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-tool-item:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 43, 73, 0.12);
  box-shadow: 0 2px 12px rgba(0, 43, 73, 0.06);
  transform: translateY(-1px);
}

.modal-tool-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.modal-tool-name {
  font-family: 'DM Sans', 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-tool-url {
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-tool-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* -- Modal Action Buttons (list view) -- */
.modal-btn-edit,
.modal-btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: 7px;
  background: var(--white);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  color: var(--gray-600);
}

.modal-btn-edit:hover {
  color: var(--blue-500);
  border-color: var(--blue-300);
  background: var(--blue-50);
}

.modal-btn-delete:hover {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fef2f2;
}

.modal-btn-edit:active,
.modal-btn-delete:active {
  transform: scale(0.96);
}

.modal-btn-edit:focus-visible,
.modal-btn-delete:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 1px;
}

/* -- Vertical Move Button Group -- */
.modal-btn-move-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
}

.modal-btn-move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--border-default);
  background: var(--white);
  color: var(--gray-400);
  cursor: pointer;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-btn-move-up {
  border-radius: 5px 5px 0 0;
  border-bottom: none;
}

.modal-btn-move-down {
  border-radius: 0 0 5px 5px;
}

.modal-btn-move:hover {
  color: var(--blue-500);
  border-color: var(--blue-300);
  background: var(--blue-50);
}

.modal-btn-move.disabled {
  color: var(--gray-300);
  border-color: var(--gray-200);
  background: var(--gray-50);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.45;
}

.modal-btn-move.disabled:hover {
  color: var(--gray-300);
  border-color: var(--gray-200);
  background: var(--gray-50);
}

.modal-btn-move:active:not(.disabled) {
  background: var(--gray-100);
}

.modal-btn-move:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: -2px;
}

/* -- Footer Actions -- */
.modal-footer-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(0, 43, 73, 0.06);
}

.modal-btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 42px;
  padding: 0 20px;
  border: 1.5px dashed rgba(0, 43, 73, 0.15);
  border-radius: 10px;
  background: rgba(0, 43, 73, 0.02);
  color: var(--blue-500);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.modal-btn-add:hover {
  background: var(--blue-50);
  border-color: var(--blue-300);
  border-style: solid;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 43, 73, 0.08);
}

.modal-btn-add:active {
  transform: translateY(0) scale(0.98);
}

.modal-btn-add:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 1px;
}

/* ===== Modal Content: Forms ===== */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-form-group label {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.required {
  color: #dc2626;
  font-weight: 400;
  margin-left: 2px;
}

.modal-form-group input[type="text"],
.modal-form-group input[type="url"] {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  background: var(--white);
  color: var(--gray-900);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  width: 100%;
}

.modal-form-group input[type="text"]::placeholder,
.modal-form-group input[type="url"]::placeholder {
  color: var(--gray-400);
}

.modal-form-group input[type="text"]:hover,
.modal-form-group input[type="url"]:hover {
  border-color: var(--gray-300);
}

.modal-form-group input[type="text"]:focus,
.modal-form-group input[type="url"]:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(0, 66, 112, 0.1);
}

.modal-form-group input[type="text"]:invalid:not(:placeholder-shown),
.modal-form-group input[type="url"]:invalid:not(:placeholder-shown) {
  border-color: #fca5a5;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.06);
}

.modal-input-readonly {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: var(--gray-50);
  color: var(--gray-500);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  cursor: not-allowed;
  width: 100%;
  outline: none;
}

.modal-form-error {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #dc2626;
  min-height: 16px;
  line-height: 1.3;
}

.modal-form-hint {
  font-family: 'Inter', 'PingFang SC', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-400);
}

/* -- Icon Preview -- */
.modal-icon-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--gray-50);
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-icon-preview svg {
  width: 100%;
  height: 100%;
  display: block;
}

.modal-icon-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.modal-icon-preview.hidden {
  display: none;
}

/* -- Form Action Buttons (save/cancel) -- */
.modal-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 43, 73, 0.06);
}

.modal-btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 20px;
  border: 1px solid var(--border-default);
  border-radius: 9px;
  background: var(--white);
  color: var(--gray-600);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.modal-btn-cancel:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.modal-btn-cancel:active {
  transform: scale(0.97);
}

.modal-btn-cancel:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 1px;
}

.modal-btn-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 24px;
  border: none;
  border-radius: 9px;
  background: var(--blue-500);
  color: var(--white);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 43, 73, 0.15);
}

.modal-btn-save:hover {
  background: var(--blue-600);
  box-shadow: 0 2px 8px rgba(0, 43, 73, 0.25);
  transform: translateY(-1px);
}

.modal-btn-save:active {
  transform: translateY(0) scale(0.97);
}

.modal-btn-save:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 2px;
}

.modal-btn-save:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ===== Scrollbar Styling (modal body) ===== */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 3px;
  transition: background 0.2s;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--gray-300);
}

/* Mobile: fullscreen modal */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
  }
  .modal-container {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
  }
}