:root {
  --bg: #0b0616;
  --text: #f4f1ff;
  --muted: #b7b0d0;
  --line: rgba(150, 130, 210, 0.28);
  --card: rgba(24, 18, 48, 0.78);
  --inset: rgba(10, 8, 24, 0.55);
  --purple: #7c5cff;
  --purple-2: #8d6bff;
  --mono: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 100% -10%, rgba(109, 70, 230, 0.28), transparent 55%),
    radial-gradient(700px 420px at 0% 100%, rgba(70, 30, 140, 0.22), transparent 50%),
    var(--bg);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: rgba(124, 92, 255, 0.45); }

.wave {
  position: absolute;
  top: 0;
  right: 0;
  width: min(640px, 52vw);
  height: 320px;
  pointer-events: none;
  z-index: 0;
}
.wave svg { width: 100%; height: 100%; display: block; }

.top, main { position: relative; z-index: 1; }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 16px;
}
.brand svg { width: 26px; height: 26px; }

main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 40px;
}
.hero-block { padding: 34px 0 18px; }
h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.035em;
}
.lede {
  margin: 8px 0 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
}
.form-card { margin-bottom: 14px; }
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: rgba(8, 6, 20, 0.45);
}
.tabs button {
  border: 0;
  background: transparent;
  color: #d9d3ee;
  border-radius: 9px;
  padding: 7px 16px;
  font-weight: 650;
}
.tabs button.active {
  background: linear-gradient(180deg, #8d6bff, #6a45f5);
  color: #fff;
  box-shadow: 0 6px 14px rgba(106, 69, 245, 0.35);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}
label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label span { color: var(--muted); font-size: 13px; }
input, select {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(160, 140, 220, 0.28);
  background: #120e22;
  padding: 0 12px;
  outline: none;
}
input:focus, select:focus { border-color: #8d6bff; }
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23c4b5fd' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
input[aria-invalid="true"] { border-color: #f07178; }
.calc-btn {
  height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #8d6bff, #6a45f5);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(106, 69, 245, 0.38);
}
.calc-btn svg { width: 18px; height: 18px; }
.calc-btn:hover { filter: brightness(1.08); }
.err {
  margin: 12px 0 0;
  color: #ffb4bc;
  background: rgba(240, 80, 100, 0.12);
  border: 1px solid rgba(240, 80, 100, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.results { margin-top: 0; }
.results-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}
.check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3ddc84;
  display: grid;
  place-items: center;
}
.check svg { width: 14px; height: 14px; }
.results-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: start;
}
.result-table { display: flex; flex-direction: column; gap: 6px; }
.tr {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: rgba(8, 6, 20, 0.42);
  border: 1px solid rgba(130, 110, 190, 0.16);
  border-radius: 10px;
  padding: 9px 12px;
}
.tr .k { color: var(--muted); font-size: 13px; }
.tr .v {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
}
.tr:hover .v { color: #ddd6fe; }

.viz {
  border: 1px solid rgba(130, 110, 190, 0.22);
  border-radius: 14px;
  background: rgba(8, 6, 20, 0.28);
  padding: 14px 14px 16px;
  min-height: 100%;
}
.viz h3 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.track {
  display: flex;
  align-items: center;
  margin: 36px 4px 14px;
}
.track .node {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e8e4f8;
  box-shadow: 0 0 0 5px rgba(180, 160, 255, 0.16);
  flex: none;
}
.track .line { height: 2px; flex: 1; background: rgba(180, 160, 255, 0.35); }
.track .hosts {
  height: 8px;
  flex: 1.35;
  border-radius: 99px;
  background: linear-gradient(90deg, #6d4dff, #c4b5fd);
  box-shadow: 0 0 18px rgba(140, 100, 255, 0.75);
}
.viz-labels {
  display: grid;
  grid-template-columns: 0.85fr 1.7fr 0.85fr;
  gap: 8px;
}
.viz-labels b {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.viz-labels span { color: var(--muted); font-size: 11px; }
.viz-labels div:first-child { text-align: left; }
.viz-labels .mid { text-align: center; }
.viz-labels .mid b { color: #d6cbff; }
.viz-labels div:last-child { text-align: right; }
.note { margin: 12px 0 0; color: #f3d48a; font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  background: #1a1430;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  transition: 0.15s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .form-row, .results-grid { grid-template-columns: 1fr; }
  .calc-btn { width: 100%; justify-content: center; }
  .wave { opacity: 0.45; }
  .viz-labels { grid-template-columns: 1fr; }
  .viz-labels div, .viz-labels .mid, .viz-labels div:last-child { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
