:root {
  --bg: #0f1e34;
  --card: #101b2b;
  --card-strong: #0c1726;
  --primary: #1c7df2;
  --accent: #2aa3ff;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --glass: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 10% 20%, rgba(28, 125, 242, 0.16), transparent 35%),
    radial-gradient(circle at 85% 0%, rgba(15, 30, 64, 0.45), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(30, 64, 120, 0.18), transparent 45%),
    var(--bg);
  font-family: 'Chakra Petch', 'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  opacity: 0.35;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  filter: blur(80px);
  opacity: 0.7;
  mix-blend-mode: screen;
  z-index: 0;
}

.glow-a {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(51, 194, 255, 0.4), transparent 60%);
  top: -140px;
  right: 12%;
  animation: float 12s ease-in-out infinite;
}

.glow-b {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(28, 125, 242, 0.3), transparent 60%);
  bottom: -160px;
  left: 6%;
  animation: float 14s ease-in-out infinite reverse;
}

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  padding: 48px 6vw 24px;
  align-items: center;
}

.hero-text h1 {
  font-size: clamp(36px, 6vw, 56px);
  margin: 10px 0;
  letter-spacing: -0.02em;
}

.subtitle {
  max-width: 620px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.6;
}

.eyebrow {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(28, 125, 242, 0.1);
  border: 1px solid rgba(28, 125, 242, 0.25);
  border-radius: 999px;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.hero-actions .btn.primary {
  padding: 14px 24px;
  font-size: 16px;
  box-shadow: 0 14px 40px rgba(28, 125, 242, 0.25);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: #0f1b2b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 18px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.modal-text {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal .btn {
  font-size: 15px;
  padding: 10px 14px;
}

.ai-modal {
  max-width: 640px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.modal-body {
  max-height: 60vh;
  overflow: auto;
  color: var(--text);
  line-height: 1.6;
}

.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

.modal-body h3,
.modal-body h4 {
  margin: 12px 0 6px;
}

.modal-body p {
  margin: 6px 0;
}

.modal-body ul {
  padding-left: 18px;
  margin: 6px 0 10px;
}

.modal-body li {
  margin: 4px 0;
}

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.97);
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(28, 125, 242, 0.9), rgba(12, 23, 38, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
  color: #f8fbff;
  min-width: 260px;
  opacity: 0;
  transform-origin: center;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 30;
}

.toast.active {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast.success {
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.92), rgba(12, 23, 38, 0.95));
  border-color: rgba(46, 204, 113, 0.35);
}

.toast.error {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.92), rgba(12, 23, 38, 0.95));
  border-color: rgba(244, 67, 54, 0.35);
}

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

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.hero-visual {
  position: relative;
  justify-self: flex-end;
}

.radar {
  position: relative;
  width: min(360px, 70vw);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle, rgba(90, 200, 255, 0.12), rgba(44, 123, 255, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
}

.radar .ring {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

.radar .ring.r2 {
  inset: 24%;
}
.radar .ring.r3 {
  inset: 36%;
}

.sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, rgba(90, 200, 255, 0.4), transparent 45%);
  animation: spin var(--radar-period, 5s) linear infinite;
  filter: blur(0.4px);
}

.radar-points {
  position: absolute;
  inset: 0;
}

.radar-points span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(138, 229, 255, 0.9);
  box-shadow: 0 0 10px rgba(138, 229, 255, 0.6);
  animation: blink 2.2s ease-in-out infinite;
  opacity: 0;
}

.pulse-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8ae5ff;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px rgba(90, 200, 255, 0.8);
  animation: blink 1.6s infinite;
}

.floating-chip {
  display: none;
}

.floating-chip strong {
  display: block;
  color: var(--primary);
  letter-spacing: 0.04em;
}

.layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 0 6vw 42px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.05), rgba(16, 31, 57, 0.6));
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.metric h2 {
  margin: 8px 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.metric.metric-good {
  background: rgba(15, 157, 88, 0.12);
  border-color: rgba(15, 157, 88, 0.25);
  box-shadow: 0 10px 30px rgba(15, 157, 88, 0.15);
}

.metric.metric-mid {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.25);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.15);
}

.metric.metric-bad {
  background: rgba(217, 48, 37, 0.12);
  border-color: rgba(217, 48, 37, 0.25);
  box-shadow: 0 10px 30px rgba(217, 48, 37, 0.18);
}

.tag {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 13px;
}

.label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.hint {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 13px;
}

.bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 6px;
}

.fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(120deg, rgba(42, 163, 255, 0.3), rgba(42, 163, 255, 0.8), rgba(42, 163, 255, 0.3));
  transition: width 0.25s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 12px rgba(42, 163, 255, 0.4);
  opacity: 0.95;
}

.fill.active {
  animation: progress-wave 1.1s linear infinite;
  background-size: 200% 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.upload-progress {
  margin-top: 6px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(15, 40, 80, 0.08);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(15, 40, 80, 0.12);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s ease;
}

.upload-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h3 {
  margin: 4px 0 0;
}

.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.node-card {
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 248, 255, 0.95));
  border: 1px solid rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.node-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 0%, rgba(44, 123, 255, 0.16), transparent 45%);
  pointer-events: none;
}

.node-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
}

.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 12px;
}

.latency {
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: space-between;
}

.latency-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.latency-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

.state {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid;
}

.state.good {
  color: #0f9d58;
  border-color: rgba(15, 157, 88, 0.25);
  background: rgba(15, 157, 88, 0.1);
}

.state.mid {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.12);
}

.state.bad {
  color: #d93025;
  border-color: rgba(217, 48, 37, 0.25);
  background: rgba(217, 48, 37, 0.1);
}

.log {
  height: 210px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 10px;
  overflow-y: auto;
  font-family: 'Chakra Petch', 'Manrope', monospace;
  font-size: 13px;
}

.log-line {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(15, 40, 80, 0.08);
  color: var(--muted);
}

.chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(28, 125, 242, 0.08);
  border: 1px solid rgba(28, 125, 242, 0.16);
  color: var(--muted);
}

.btn {
  cursor: pointer;
  border: 0;
  padding: 12px 16px;
  border-radius: 12px;
  color: #0b0b12;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 12px 35px rgba(28, 125, 242, 0.15);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.btn.small {
  padding: 9px 12px;
  font-weight: 600;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

@keyframes blink {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
}

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

@keyframes ping {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.9;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0;
  }
}

@keyframes blink {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 0.4; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@media (max-width: 720px) {
  .hero {
    padding-top: 46px;
  }
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
