@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root,
html[data-theme="light"] {
  --bg: #eef3f8;
  --bg-elev: #ffffff;
  --bg-soft: #f5f8fc;
  --bg-top: rgba(255, 255, 255, 0.82);
  --line: #d7e0ea;
  --text: #152033;
  --muted: #66788c;
  --accent: #0b7ddb;
  --accent-2: #0862b0;
  --accent-soft: rgba(11, 125, 219, 0.1);
  --ok: #0f9f6e;
  --bad: #d94444;
  --warn: #c48912;
  --hero-from: #f7fbff;
  --hero-to: #e8f1fa;
  --glow-1: rgba(64, 148, 220, 0.22);
  --glow-2: rgba(20, 180, 150, 0.12);
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.06);
  --shadow-sm: 0 4px 14px rgba(21, 32, 51, 0.05);
  --code-bg: #eaf0f6;
  --snippet-fg: #334155;
  --alert-ok-bg: rgba(15, 159, 110, 0.1);
  --alert-ok-fg: #0b6b4a;
  --alert-err-bg: rgba(217, 68, 68, 0.1);
  --alert-err-fg: #a52828;
  --radius: 16px;
  --font: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

html[data-theme="dark"] {
  --bg: #0e141b;
  --bg-elev: #161d27;
  --bg-soft: #1b2430;
  --bg-top: rgba(14, 20, 27, 0.82);
  --line: #2a3544;
  --text: #e8eef6;
  --muted: #8b9aab;
  --accent: #3ea0f0;
  --accent-2: #2b7fc4;
  --accent-soft: rgba(62, 160, 240, 0.14);
  --ok: #3ecf8e;
  --bad: #ef6b6b;
  --warn: #e2b340;
  --hero-from: #182433;
  --hero-to: #121b26;
  --glow-1: rgba(40, 110, 180, 0.28);
  --glow-2: rgba(20, 90, 80, 0.18);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.2);
  --code-bg: #101821;
  --snippet-fg: #c9d6e4;
  --alert-ok-bg: rgba(62, 207, 142, 0.12);
  --alert-ok-fg: #b9f0d4;
  --alert-err-bg: rgba(239, 107, 107, 0.12);
  --alert-err-fg: #ffc5c5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 8% -8%, var(--glow-1), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, var(--glow-2), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
  transition: background 0.25s ease, color 0.25s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .doh-url, .mono { font-family: var(--mono); }
code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.92em;
}
.muted { color: var(--muted); }
label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input, button, select { font: inherit; }
input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button {
  border: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.12s ease, filter 0.12s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}
.btn-danger {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad);
}
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}
.theme-btn .ico { font-size: 14px; line-height: 1; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.auth-wrap .theme-float {
  position: absolute;
  top: 20px;
  right: 20px;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-sub {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}
.auth-card button { width: 100%; margin-top: 18px; padding: 12px 16px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: var(--bg-top);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.brand-inline {
  font-size: 18px;
  font-weight: 800;
  margin-right: 10px;
  letter-spacing: -0.02em;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  gap: 18px;
}

.hero-strip {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.hero-strip h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.hero-strip p { margin: 0; color: var(--muted); line-height: 1.65; }
.doh-box {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.doh-box .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doh-url {
  display: block;
  color: var(--ok);
  word-break: break-all;
  margin-bottom: 12px;
  font-weight: 600;
}
.snippet {
  margin: 0;
  background: var(--code-bg);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  color: var(--snippet-fg);
  overflow: auto;
  border: 1px solid var(--line);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .num { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 600; }
.stat.ok .num { color: var(--ok); }
.stat.bad .num { color: var(--bad); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.card > .muted { margin: 0 0 14px; line-height: 1.55; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr auto;
  gap: 10px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.8fr auto;
  gap: 10px;
}
.form-add-node {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px 12px;
}
.field { display: grid; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.actions-row { display: flex; justify-content: flex-start; }

.ip-editor {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.ip-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 8px;
  margin-bottom: 10px;
}
.ip-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 8px 6px 10px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.ip-chip.v4 {
  color: #0b6aa8;
  background: rgba(11, 125, 219, 0.12);
  border-color: rgba(11, 125, 219, 0.22);
}
.ip-chip.v6 {
  color: #0f7a58;
  background: rgba(15, 159, 110, 0.12);
  border-color: rgba(15, 159, 110, 0.22);
}
.ip-chip.host {
  color: #9a5b00;
  background: rgba(196, 137, 18, 0.14);
  border-color: rgba(196, 137, 18, 0.28);
}
html[data-theme="dark"] .ip-chip.v4 {
  color: #8fd0ff;
  background: rgba(62, 160, 240, 0.14);
  border-color: rgba(62, 160, 240, 0.28);
}
html[data-theme="dark"] .ip-chip.v6 {
  color: #7ee0b5;
  background: rgba(62, 207, 142, 0.14);
  border-color: rgba(62, 207, 142, 0.28);
}
html[data-theme="dark"] .ip-chip.host {
  color: #ffd27a;
  background: rgba(226, 179, 64, 0.16);
  border-color: rgba(226, 179, 64, 0.3);
}
.ip-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ip-chip-x {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
html[data-theme="dark"] .ip-chip-x { background: rgba(255, 255, 255, 0.08); }
.ip-chip-x:hover { filter: brightness(0.95); }

.ip-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.node-ip-form .ip-add-row {
  grid-template-columns: 1fr auto auto;
}
.ip-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.node-list {
  display: grid;
  gap: 12px;
}
.node-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
}
.node-item.is-off { opacity: 0.72; }
.node-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.node-title code {
  font-size: 14px;
  font-weight: 700;
}
.node-note {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.node-ops {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.node-ops form { margin: 0; }
.form-stack { display: grid; gap: 10px; }

.table-wrap { overflow: auto; border-radius: 12px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ops { display: flex; gap: 8px; }
.ops form { margin: 0; }
.answer {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty { color: var(--muted); margin: 8px 0 0; }

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid transparent;
  font-weight: 700;
}
.tag-ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 28%, transparent);
}
.tag-bad {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border-color: color-mix(in srgb, var(--bad) 28%, transparent);
}
.tag-off {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  border-color: color-mix(in srgb, var(--muted) 28%, transparent);
}

.row-bad td { background: color-mix(in srgb, var(--bad) 4%, transparent); }
.row-ok td { background: color-mix(in srgb, var(--ok) 4%, transparent); }

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  font-weight: 600;
}
.alert-ok {
  background: var(--alert-ok-bg);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--alert-ok-fg);
}
.alert-err {
  background: var(--alert-err-bg);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
  color: var(--alert-err-fg);
}

@media (max-width: 860px) {
  .hero-strip, .grid-2, .stats, .form-row, .form-row-3, .form-add-node,
  .ip-add-row, .node-ip-form .ip-add-row, .node-item {
    grid-template-columns: 1fr;
  }
  .hero-strip h1 { font-size: 22px; }
  .node-ops { flex-direction: row; }
}
