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

:root {
  --bg: #050008;
  --border: rgba(168, 85, 247, 0.22);
  --text: #ffffff;
  --muted: #cbb9dd;
  --purple: #a855f7;
  --purple2: #7e22ce;
  --purple3: #c084fc;
  --green: #22c55e;
  --red: #f87171;
}

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 12%, rgba(147, 51, 234, 0.42), transparent 30%),
    radial-gradient(circle at 82% 8%, rgba(192, 132, 252, 0.28), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(88, 28, 135, 0.42), transparent 36%),
    linear-gradient(180deg, #050008 0%, #09000f 45%, #050008 100%);
  z-index: -2;
}

::selection {
  background: rgba(168,85,247,0.55);
  color: white;
}

a { color: inherit; text-decoration: none; }

header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 7%;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(9, 0, 18, 0.86), rgba(5, 0, 8, 0.68));
  border-bottom: 1px solid rgba(192,132,252,0.16);
  backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.32);
}

.logo {
  display: flex;
  align-items: center;
  min-width: 190px;
}

.logo img {
  height: 58px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(168,85,247,0.35));
}

nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: #d9c8ee;
  font-weight: 700;
  font-size: 0.9rem;
}

nav a {
  position: relative;
  transition: .22s ease;
  white-space: nowrap;
}

nav a:not(.nav-btn):not(.nav-dropdown-btn)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--purple3), transparent);
  transform: scaleX(0);
  transition: .22s ease;
}

nav a:hover { color: white; }
nav a:hover::after { transform: scaleX(1); }
nav a.active { color: white; }
nav a.active::after { transform: scaleX(1); }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(192,132,252,0.35);
  background: rgba(168,85,247,0.12);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
}
.menu-toggle svg { display: block; }
.menu-toggle .icon-close { display: none; }
.menu-toggle.open .icon-menu { display: none; }
.menu-toggle.open .icon-close { display: block; }

.mobile-nav {
  display: none;
  position: fixed;
  inset: 70px 0 0 0;
  z-index: 19;
  padding: 20px 5% 32px;
  background: rgba(5, 0, 8, 0.96);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(192,132,252,0.16);
  overflow-y: auto;
  flex-direction: column;
  gap: 6px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 14px 16px;
  border-radius: 12px;
  color: #d9c8ee;
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid transparent;
  transition: 0.18s ease;
}
.mobile-nav a:hover, .mobile-nav a.active {
  color: white;
  background: rgba(168,85,247,0.14);
  border-color: rgba(168,85,247,0.28);
}
.mobile-nav .mobile-group {
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-nav .mobile-group span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 4px;
}

.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 12px;
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  border: 1px solid rgba(192,132,252,0.48);
  color: white;
  box-shadow: 0 0 24px rgba(168,85,247,0.35);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.nav-dropdown-btn svg { transition: transform 0.2s ease; }
.nav-dropdown.open .nav-dropdown-btn svg { transform: rotate(180deg); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: #1a0f2e;
  border: 1px solid rgba(168,85,247,0.35);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 20px rgba(168,85,247,0.15);
  z-index: 999;
  flex-direction: column;
  gap: 2px;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  color: #d9c8ee;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.18s, color 0.18s;
}
.nav-dropdown-menu a:hover { background: rgba(168,85,247,0.18); color: white; }
.nav-dropdown-menu a::after { display: none !important; }
.nav-dropdown-menu .dd-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--purple3);
  outline-offset: 3px;
}

main { flex: 1; }

.tool-page {
  padding: 48px 7% 72px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.tool-header {
  text-align: center;
  margin-bottom: 36px;
}

.tool-header .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: #f0ddff;
  background: rgba(168, 85, 247, 0.13);
  border: 1px solid rgba(168, 85, 247, 0.38);
  font-weight: 700;
  font-size: 0.86rem;
  margin-bottom: 18px;
}

.tool-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.05em;
  margin-bottom: 12px;
}

.tool-header p {
  color: var(--muted);
  line-height: 1.7;
  max-width: 640px;
  margin: 0 auto;
}

.tool-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.tool-nav a {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(168,85,247,0.28);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  transition: 0.2s ease;
}
.tool-nav a:hover { color: white; border-color: rgba(192,132,252,0.5); }
.tool-nav a.active {
  color: white;
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  border-color: rgba(192,132,252,0.55);
  box-shadow: 0 0 28px rgba(168,85,247,0.35);
}

.tool-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.038));
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 28px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 22px 65px rgba(0,0,0,0.16);
}

.tool-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.tool-input {
  flex: 1;
  min-width: 220px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
}
.tool-input::placeholder { color: #8f7da8; }

.tool-select {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-family: inherit;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: 0.22s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, #a855f7, #7e22ce);
  box-shadow: 0 0 34px rgba(147, 51, 234, 0.4);
  color: white;
}
.btn-secondary {
  background: rgba(255,255,255,0.065);
  border: 1px solid rgba(255,255,255,0.13);
  color: white;
}

.result-box {
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.28);
  overflow: hidden;
}

.result-box.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.result-table th,
.result-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  vertical-align: top;
}
.result-table th {
  color: var(--purple3);
  font-weight: 800;
  background: rgba(168,85,247,0.08);
  width: 180px;
}
.result-table tr:last-child th,
.result-table tr:last-child td { border-bottom: none; }
.result-table td { color: #e8dcf5; word-break: break-word; }

.status-msg {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 0.92rem;
}
.status-msg.loading {
  background: rgba(168,85,247,0.12);
  border: 1px solid rgba(168,85,247,0.28);
  color: #e9d5ff;
}
.status-msg.error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.28);
  color: #fecaca;
}
.status-msg.success {
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.28);
  color: #bbf7d0;
}

.speedtest-frame {
  width: 100%;
  min-height: 620px;
  border: none;
  border-radius: 18px;
  display: block;
  background: rgba(0,0,0,0.2);
}

.record-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.record-block {
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}
.record-block h3 {
  padding: 12px 18px;
  font-size: 0.95rem;
  background: rgba(168,85,247,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--purple3);
}
.record-block ul {
  list-style: none;
  padding: 12px 18px;
}
.record-block li {
  padding: 8px 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.record-block li:last-child { border-bottom: none; }
.record-block .no-records {
  padding: 16px 18px;
  color: #8f7da8;
  font-size: 0.9rem;
}

footer {
  padding: 36px 7%;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  color: #a999bc;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.footer-links a:hover { color: white; }

@media (max-width: 960px) {
  nav { display: none; }
  .menu-toggle { display: flex; }
}

@media (max-width: 720px) {
  header { padding: 12px 5%; min-height: 70px; }
  .logo img { height: 46px; }
  .tool-page { padding: 36px 5% 56px; }
  .tool-form { flex-direction: column; }
  .tool-input, .tool-select, .btn { width: 100%; }
  .result-table th { width: 120px; }
  .speedtest-frame { min-height: 520px; }
}