:root {
  --bg: #0f1420;
  --bg-card: #171d2b;
  --bg-input: #0d1220;
  --border: #2a3348;
  --text: #e6ebf5;
  --muted: #8b97b0;
  --accent: #6ea8fe;
  --accent-2: #b18cff;
  --good: #46d19e;
  --warn: #f4bf5f;
  --bad: #ff6b6b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5fa;
    --bg-card: #ffffff;
    --bg-input: #f7f9fc;
    --border: #d9dfec;
    --text: #1b2233;
    --muted: #5b6580;
    --accent: #2f6bd8;
    --accent-2: #7a4fd0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

.site-header {
  background: linear-gradient(135deg, rgba(110,168,254,0.12), rgba(177,140,255,0.12));
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.site-header .wrap { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.site-header h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.02em; }
.logo { filter: saturate(1.2); }
.tagline { margin: 0; color: var(--muted); font-size: 0.9rem; }

main.wrap { padding-top: 1.25rem; padding-bottom: 3rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.field { margin-bottom: 1rem; display: flex; flex-direction: column; }
.field > label, legend { font-weight: 600; margin-bottom: 0.4rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85em; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

textarea, input[type=text], select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  width: 100%;
}
textarea { font-family: var(--mono); resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.options { gap: 0.35rem; }
.check { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

.resolvers { border: 1px solid var(--border); border-radius: 10px; padding: 0.85rem 1rem 1rem; }
.resolvers legend { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.25rem; }
.count-pill {
  font-size: 0.75rem; font-weight: 600; color: var(--accent);
  background: rgba(110,168,254,0.14); border-radius: 999px; padding: 0.05rem 0.55rem;
}
.count-pill.none { color: var(--bad); background: rgba(255,107,107,0.14); }

.resolver-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center;
  justify-content: space-between; margin-bottom: 0.5rem;
}
.preset-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.preset {
  background: transparent; color: var(--text); border: none; font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
}
.preset + .preset { border-left: 1px solid var(--border); }
.preset:hover { background: rgba(127,127,127,0.12); }
.custom-add { display: flex; gap: 0.4rem; flex: 1 1 260px; max-width: 360px; }
.custom-add input { padding: 0.35rem 0.6rem; font-size: 0.88rem; font-family: var(--mono); }
.ghost.small { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

.resolver-group { margin-top: 0.6rem; }
.resolver-group-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; }
.resolver-group-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.group-toggle {
  background: none; border: none; color: var(--accent); font-size: 0.75rem; padding: 0;
}
.group-toggle:hover { text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.chip {
  display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input);
  padding: 0.35rem 0.75rem 0.35rem 0.55rem; min-width: 0;
  transition: border-color 0.12s, background 0.12s;
}
.chip:hover { border-color: var(--muted); }
.chip-check {
  flex: none; width: 1rem; height: 1rem; border-radius: 4px;
  border: 1.5px solid var(--muted); display: grid; place-items: center;
}
.chip-body { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.chip-name { font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 0.35rem; }
.chip-addr { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.proto-tag {
  font-size: 0.65rem; font-weight: 700; color: var(--accent-2); border: 1px solid currentColor;
  border-radius: 4px; padding: 0 0.25rem; letter-spacing: 0.03em;
}
.chip:has(input:checked) { border-color: var(--accent); background: rgba(110,168,254,0.12); }
.chip:has(input:checked) .chip-check { background: var(--accent); border-color: var(--accent); }
.chip:has(input:checked) .chip-check::after {
  content: ""; width: 0.28rem; height: 0.55rem; border: solid #04102b;
  border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg);
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-wrap { display: inline-flex; align-items: center; }
.chip-wrap .chip { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.chip-remove {
  align-self: stretch; background: var(--bg-input); color: var(--muted);
  border: 1px solid var(--border); border-left: none; border-radius: 0 10px 10px 0;
  padding: 0 0.55rem; font-size: 1rem;
}
.chip-remove:hover { color: var(--bad); }

button { cursor: pointer; font-family: var(--sans); }
.link {
  background: none; border: none; color: var(--accent); padding: 0.2rem 0.35rem;
  font-size: 0.9rem; text-decoration: underline; border-radius: 6px;
}
.primary {
  background: var(--accent); color: #04102b; border: none; font-weight: 700;
  padding: 0.6rem 1.2rem; border-radius: 8px; font-size: 1rem;
}
.primary:disabled { opacity: 0.6; cursor: progress; }
.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
  padding: 0.6rem 0.9rem; border-radius: 8px;
}
.actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.status { color: var(--muted); font-size: 0.9rem; }

.results { margin-top: 0.5rem; }

.host-tabs { padding: 0; overflow: hidden; }
.tablist { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: thin; }
.host-tabs > .tablist {
  padding: 0.5rem 0.75rem 0; border-bottom: 1px solid var(--border);
  background: rgba(127,127,127,0.05);
}
.tab {
  display: inline-flex; align-items: center; gap: 0.45rem; white-space: nowrap;
  background: none; border: none; color: var(--muted); font-size: 0.92rem;
  padding: 0.5rem 0.85rem; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.host-tabs > .tablist .tab-label { font-family: var(--mono); }
.tab-badge {
  font-size: 0.7rem; font-weight: 700; min-width: 1.2rem; text-align: center;
  border-radius: 999px; padding: 0 0.35rem; line-height: 1.2rem;
}
.tab-badge.bad { background: rgba(255,107,107,0.18); color: var(--bad); }
.tab-badge.warn { background: rgba(244,191,95,0.18); color: var(--warn); }
.host-tabs > .tabpanel { padding: 0.9rem; }

.resolver-tabs > .tablist { margin-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.resolver-tabs .tab { font-size: 0.85rem; padding: 0.35rem 0.7rem; }

table.compare { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.86rem; }
table.compare th, table.compare td {
  text-align: left; vertical-align: top; padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
table.compare tr:first-child th { font-weight: 600; border-bottom-width: 2px; }
table.compare .col-name { display: block; }
table.compare .col-meta { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; font-family: var(--mono); }
table.compare th[scope=row] { width: 1%; white-space: nowrap; }
table.compare td .data { font-family: var(--mono); word-break: break-all; }
table.compare td.muted { color: var(--muted); }
table.compare td.bad { color: var(--bad); font-weight: 600; }
table.compare tr.differs { background: rgba(244,191,95,0.07); }
table.compare tr:last-child th, table.compare tr:last-child td { border-bottom: none; }
.differs-tag { display: block; color: var(--warn); font-size: 0.7rem; font-weight: 600; margin-top: 0.25rem; }

.type-badge {
  font-family: var(--mono); font-weight: 700; background: var(--accent);
  color: #04102b; padding: 0.05rem 0.5rem; border-radius: 6px; font-size: 0.82rem;
}

.result {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 0.75rem; overflow: hidden;
}
.result-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border);
  background: rgba(127,127,127,0.05);
}
.result-head .resolver-name { font-weight: 600; }
.result-head .meta { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

.status-badge { font-size: 0.78rem; padding: 0.05rem 0.45rem; border-radius: 6px; font-weight: 700; }
.status-NOERROR { background: rgba(70,209,158,0.18); color: var(--good); }
.status-NXDOMAIN { background: rgba(244,191,95,0.18); color: var(--warn); }
.status-ERROR, .status-SERVFAIL, .status-REFUSED { background: rgba(255,107,107,0.18); color: var(--bad); }

table.records { width: 100%; min-width: 34rem; table-layout: fixed; border-collapse: collapse; font-family: var(--mono); font-size: 0.86rem; }
table.records th, table.records td { text-align: left; padding: 0.35rem 0.9rem; border-bottom: 1px solid var(--border); }
table.records th { color: var(--muted); font-weight: 600; font-family: var(--sans); font-size: 0.8rem; }
table.records th:nth-child(1) { width: 30%; }
table.records td:first-child { overflow-wrap: anywhere; }
table.records th:nth-child(2) { width: 4.5rem; }
table.records th:nth-child(3) { width: 5rem; }
table.records tr:last-child td { border-bottom: none; }
table.records td.data { word-break: break-all; }
.records-wrap { overflow-x: auto; }

.empty-note, .error-note { padding: 0.6rem 0.9rem; color: var(--muted); font-size: 0.9rem; }
.error-note { color: var(--bad); }

.trace { padding: 0.6rem 0.9rem; }
.trace-step { border-left: 2px solid var(--border); padding: 0.15rem 0 0.15rem 0.75rem; margin-bottom: 0.4rem; }
.trace-step .zone { color: var(--accent-2); font-family: var(--mono); }
.trace-step .srv { color: var(--muted); font-size: 0.85em; }
.trace-step ul { margin: 0.2rem 0 0; padding-left: 1rem; font-family: var(--mono); font-size: 0.82rem; }

.api-help pre {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.8rem; overflow-x: auto; font-size: 0.82rem;
}
.api-help summary { cursor: pointer; font-weight: 600; }

.site-footer {
  display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center;
  color: var(--muted); font-size: 0.85rem; padding-bottom: 2rem;
}
.site-footer a { color: var(--accent); }
