/* DNS 查詢站
   CSP 是 style-src 'self'，所以這支檔案之外不能有 inline style；
   JS 只用 CSSOM（element.style.width）畫耗時條，那是允許的。 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2027;
  --muted: #6b7480;
  --line: #e4e7eb;
  --soft: #f1f3f6;
  --brand: #2563eb;
  --brand-ink: #fff;
  --ok: #0f8a5f;
  --ok-bg: #e6f6ef;
  --warn: #a86400;
  --warn-bg: #fdf1dc;
  --bad: #b4232b;
  --bad-bg: #fdeaea;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 16px;
  --placeholder: #a9b0ba;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --text: #e8eaef;
    --muted: #9aa3ad;
    --line: #272b35;
    --soft: #1e222a;
    --brand: #5b8cff;
    --brand-ink: #0b1220;
    --ok: #4ecf9c;
    --ok-bg: #12301f;
    --warn: #e0a94a;
    --warn-bg: #33260e;
    --bad: #f0787f;
    --bad-bg: #33161a;
    --placeholder: #616975;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(59, 130, 246, .10), transparent 60%),
    radial-gradient(900px 480px at 92% 4%, rgba(244, 114, 182, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--panel); padding: 10px 14px;
  border-radius: 0 0 10px 0; border: 1px solid var(--line);
}
.skip:focus { left: 0; z-index: 20; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ── 頁首 ─────────────────────────────────────────────── */

.head { margin-bottom: 16px; }
.eyebrow {
  margin: 0; font-size: 12px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
h1 { font-size: 30px; line-height: 1.25; margin: 2px 0 4px; letter-spacing: -.01em; }
.lede { margin: 0; color: var(--muted); font-size: 14px; }

/* ── 查詢列 ───────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.qbar { padding: 16px; position: sticky; top: 0; z-index: 5; }

.qrow { display: flex; gap: 10px; align-items: stretch; }

.qname {
  flex: 1 1 320px; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; background: var(--panel);
}
.qname:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.qname svg { flex: none; color: var(--muted); }
.qname input {
  border: 0; outline: 0; background: transparent; color: inherit;
  font: inherit; font-size: 16px; padding: 13px 0; width: 100%;
  min-width: 0;
}
.qname input::placeholder { color: var(--placeholder); opacity: 1; }

.sel { position: relative; display: flex; align-items: center; }
.sel__label {
  position: absolute; left: 12px; top: 5px;
  font-size: 10.5px; letter-spacing: .06em; color: var(--muted);
  pointer-events: none;
}
.sel select {
  font: inherit; font-size: 14px; color: inherit;
  height: 48px; padding: 16px 34px 0 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background-color: var(--panel);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7480' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  max-width: 220px;
}
.sel select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn {
  border: 0; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 0 26px; height: 48px; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: progress; }

.qmeta {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
  margin-top: 12px; font-size: 13px; color: var(--muted);
}
.qmeta__hint { margin-left: auto; font-size: 12px; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--soft); color: var(--text);
}

.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.chk input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chk .box {
  width: 15px; height: 15px; border: 1.5px solid #c3c9d1; border-radius: 4px;
  background: var(--panel); position: relative; flex: none;
}
.chk input:checked + .box { background: var(--brand); border-color: var(--brand); }
.chk input:checked + .box::after {
  content: ""; position: absolute; left: 3.5px; top: 1px;
  width: 5px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(40deg);
}
.chk input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── 分頁 ─────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px; margin: 18px 0 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: 9px 14px; font: inherit; font-size: 14px;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-on { color: var(--text); font-weight: 600; border-color: var(--brand); }
.tab__n { font-size: 11px; color: var(--muted); margin-left: 4px; }

.pane { margin-top: 16px; }
.pane[hidden] { display: none; }

.cols {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px; align-items: start;
}

/* ── 結果卡 ───────────────────────────────────────────── */

.card__head {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card__title {
  font-size: 17px; margin: 0; font-family: var(--mono); font-weight: 600;
  letter-spacing: -.01em; word-break: break-all;
}
.card__title span { color: var(--muted); font-weight: 400; }
.card__sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 99px;
  background: var(--soft); color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip--ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.chip--bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.chip--mono { font-family: var(--mono); font-size: 11.5px; }

/* 紀錄表 */
.rrtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rrtable th {
  text-align: left; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; background: var(--soft);
  padding: 9px 18px; border-bottom: 1px solid var(--line);
}
.rrtable td { padding: 11px 18px; border-bottom: 1px solid var(--soft); vertical-align: top; }
.rrtable tr:last-child td { border-bottom: 0; }
.rrtable .ttl {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  width: 74px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.rrtable .type { width: 78px; }
.rdata { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.rdata .pre { color: var(--muted); }

.badge {
  display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 6px; letter-spacing: .03em;
}
.b-a, .b-aaaa { background: rgba(37, 99, 235, .12); color: #1a56c4; }
.b-mx, .b-dnskey { background: rgba(124, 58, 237, .13); color: #6b34c9; }
.b-ns, .b-cname { background: rgba(15, 138, 95, .13); color: var(--ok); }
.b-txt, .b-spf { background: rgba(168, 100, 0, .13); color: var(--warn); }
.b-soa, .b-rrsig { background: var(--soft); color: var(--muted); }
.b-caa, .b-tlsa, .b-ds { background: rgba(180, 35, 43, .11); color: var(--bad); }
@media (prefers-color-scheme: dark) {
  .b-a, .b-aaaa { background: rgba(91, 140, 255, .18); color: #9dbaff; }
  .b-mx, .b-dnskey { background: rgba(167, 139, 250, .18); color: #c4b1ff; }
  .b-txt, .b-spf { background: rgba(224, 169, 74, .16); color: #e0a94a; }
  .b-caa, .b-tlsa, .b-ds { background: rgba(240, 120, 127, .16); color: #f0787f; }
}

button.linkish {
  appearance: none; border: 0; background: none; padding: 0; margin: 0;
  font: inherit; color: var(--brand); cursor: pointer; text-align: left;
  text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
  word-break: break-all;
}
button.linkish:hover { text-decoration-thickness: 2px; }

.sect { border-top: 1px solid var(--soft); }
.sect > summary {
  padding: 11px 18px; cursor: pointer; font-size: 13.5px; color: var(--muted);
  list-style: none;
}
.sect > summary::-webkit-details-marker { display: none; }
.sect > summary b { color: var(--text); font-weight: 600; }
.sect > summary::before {
  content: "▸"; display: inline-block; margin-right: 8px; color: #aeb5bf;
}
.sect[open] > summary::before { transform: rotate(90deg); }

.acts { display: flex; gap: 8px; padding: 12px 18px; flex-wrap: wrap; border-top: 1px solid var(--soft); }
.ghost {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  border-radius: 9px; font: inherit; font-size: 12.5px; color: var(--muted);
  padding: 6px 11px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.ghost:hover { color: var(--text); border-color: #c9ced6; }

.empty { padding: 34px 20px; text-align: center; }
.empty__title { margin: 0 0 6px; font-size: 14.5px; }
.empty__hint { margin: 0; font-size: 13px; color: var(--muted); }

.alert {
  margin: 16px 18px; padding: 12px 14px; border-radius: 11px;
  background: var(--bad-bg); color: var(--bad); font-size: 13.5px;
}
.alert--warn { background: var(--warn-bg); color: var(--warn); }

/* ── 側欄 ─────────────────────────────────────────────── */

.side { display: grid; gap: 14px; }
.sbody { padding: 14px 16px; }
.sh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.sh h2, .sh h3 { font-size: 13px; margin: 0; letter-spacing: .02em; }
.sh__aside { font-size: 11.5px; color: var(--muted); }

.kv { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.state--ok { color: var(--ok); }
.state--bad { color: var(--bad); }
.state--muted { color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; flex: none; }

.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tile {
  appearance: none; font-family: var(--mono); font-size: 12px;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); cursor: pointer;
}
.tile:hover { border-color: var(--brand); color: var(--brand); }
.tile.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* 頁面最下方的「最近查詢」：一排可點的紀錄，只存在瀏覽器 */
.recentbar { margin-top: 18px; padding: 14px 16px; }
.recentbar .sh { margin-bottom: 10px; }
.recentbar .tile {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── 全球傳播 ─────────────────────────────────────────── */

.ptable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ptable th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; background: var(--soft);
  padding: 9px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.ptable td { padding: 10px 16px; border-bottom: 1px solid var(--soft); }
.ptable tr:last-child td { border-bottom: 0; }
.res { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.res i { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); flex: none; }
.res i.warn { background: var(--warn); }
.res i.bad { background: var(--bad); }
.res i.muted { background: var(--muted); }
.pill {
  font-size: 11.5px; padding: 2px 8px; border-radius: 99px;
  background: var(--ok-bg); color: var(--ok); font-weight: 600; white-space: nowrap;
}
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--bad { background: var(--bad-bg); color: var(--bad); }
.pill--muted { background: var(--soft); color: var(--muted); }
.lat { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.bar { height: 4px; border-radius: 99px; background: var(--soft); position: relative; width: 70px; flex: none; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: #93b4f5; }
.ms { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 44px; text-align: right; }
.answers { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.answers span { display: block; }

/* ── 授權伺服器 / 追蹤 / DNSSEC ───────────────────────── */

.nsgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; padding: 16px 18px; }
.nsbox { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.nsbox b { display: block; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.nsbox small { color: var(--muted); font-size: 11.5px; }

.steps { margin: 0; padding: 18px 18px 20px; list-style: none; }
.step { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line); }
.step:last-child { border-left-color: transparent; padding-bottom: 0; }
.step::before {
  content: ""; position: absolute; left: -7px; top: 4px;
  width: 12px; height: 12px; border-radius: 99px;
  background: var(--panel); border: 2px solid var(--brand);
}
.step--answer::before { border-color: var(--ok); background: var(--ok); }
.step__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.step__server { font-family: var(--mono); font-weight: 600; }
.step__meta { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.step__records { margin: 6px 0 0; }
.step__records .rdata { font-size: 12.5px; }

.dnsstate { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dnsstate__badge {
  font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 99px;
}
.dnsstate__badge.ok { background: var(--ok-bg); color: var(--ok); }
.dnsstate__badge.warn { background: var(--warn-bg); color: var(--warn); }
.dnsstate__badge.bad { background: var(--bad-bg); color: var(--bad); }
.dnsstate__badge.muted { background: var(--soft); color: var(--muted); }
.dnsstate p { margin: 0; font-size: 13px; color: var(--muted); }

pre.raw {
  margin: 0; padding: 14px 18px; overflow-x: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  background: var(--soft); color: var(--text);
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
  white-space: pre; tab-size: 8;
}
.cmdline {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  padding: 12px 18px; border-bottom: 1px solid var(--soft);
  overflow-x: auto; white-space: pre;
}

.note {
  margin: 26px 2px 0; font-size: 12.5px; color: var(--muted); line-height: 1.8;
}
.note code { font-family: var(--mono); font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text); color: var(--panel);
  padding: 9px 16px; border-radius: 99px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .22); z-index: 30;
  max-width: calc(100vw - 40px);
}

/* 複製功能的離屏 textarea（CSP 不允許 inline style，所以用 class） */
.copy-sink { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ── 手機 ─────────────────────────────────────────────── */

@media (max-width: 820px) {
  .wrap { padding: 18px 14px 36px; }
  h1 { font-size: 24px; }
  .lede { font-size: 13px; }
  .qbar { padding: 12px; border-radius: 14px; position: static; }
  .qrow { flex-wrap: wrap; gap: 8px; }
  .qname { flex: 1 1 100%; }
  .sel { flex: 1 1 0; min-width: 0; }
  .sel select { width: 100%; max-width: none; height: 44px; font-size: 13.5px; padding-top: 15px; }
  .btn { flex: 1 1 100%; height: 44px; }
  .qmeta { gap: 12px; font-size: 12.5px; }
  .qmeta__hint { display: none; }
  .cols { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .rrtable th, .rrtable td, .ptable th, .ptable td { padding-left: 12px; padding-right: 12px; }
  .rrtable .ttl { width: 58px; }
  .rrtable .type { width: 66px; }
  .rdata { font-size: 12.5px; }
  .ptable { font-size: 12.5px; }
  .ptable .col-region, .ptable .col-base { display: none; }
  .chips { margin-left: 0; }
  .tabs { margin-top: 14px; }
  .acts { padding: 10px 12px; }
  .card__head { padding: 13px 14px; }
}
