/* DNS 手册 — one stylesheet for every page. */

:root {
  --paper: #f6f4ee;
  --surface: #fcfbf7;
  --sunken: #eeebe3;
  --ink: #24231f;
  --ink-soft: #46443d;
  --muted: #6e695e;
  --rule: #dfdacd;
  --rule-strong: #c9c2b2;
  --accent: #2c6460;
  --accent-ink: #1f4a47;
  --accent-wash: #e2ece8;
  --ochre: #9a6a1f;
  --ochre-wash: #f3ead6;
  --brick: #9a3f2f;
  --brick-wash: #f4e3dd;
  --mark: #f1df9c;
  --code-bg: #efece4;
  --focus: #2c6460;
  --radius: 4px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --topbar: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1c1a;
    --surface: #212220;
    --sunken: #181917;
    --ink: #e6e2d7;
    --ink-soft: #cfcabd;
    --muted: #a19b8d;
    --rule: #33342f;
    --rule-strong: #46473f;
    --accent: #84b8ad;
    --accent-ink: #a7d0c6;
    --accent-wash: #24302d;
    --ochre: #d2a45e;
    --ochre-wash: #2f2a20;
    --brick: #d98a74;
    --brick-wash: #33241f;
    --mark: #5b4e22;
    --code-bg: #262723;
    --focus: #84b8ad;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1b1c1a;
  --surface: #212220;
  --sunken: #181917;
  --ink: #e6e2d7;
  --ink-soft: #cfcabd;
  --muted: #a19b8d;
  --rule: #33342f;
  --rule-strong: #46473f;
  --accent: #84b8ad;
  --accent-ink: #a7d0c6;
  --accent-wash: #24302d;
  --ochre: #d2a45e;
  --ochre-wash: #2f2a20;
  --brick: #d98a74;
  --brick-wash: #33241f;
  --mark: #5b4e22;
  --code-bg: #262723;
  --focus: #84b8ad;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

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

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 40;
  padding: 8px 14px; background: var(--ink); color: var(--paper);
  border-radius: var(--radius); text-decoration: none;
}
.skip:focus { top: 8px; color: var(--paper); }

svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ top bar */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar); padding: 0 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--ink); text-decoration: none;
  font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand svg { width: 24px; height: 24px; }
.brand small { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 2px; }

.icon-btn, .theme-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: transparent; color: var(--ink-soft);
  font: 13px/1 var(--sans); cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.icon-btn:hover, .theme-btn:hover { background: var(--sunken); border-color: var(--rule-strong); color: var(--ink); }
.icon-btn:active, .theme-btn:active { transform: translateY(1px); }
.nav-toggle { display: none; width: 34px; padding: 0; }
.theme-btn { margin-left: auto; }

.search { position: relative; flex: 0 1 420px; margin-left: 28px; }
.search > svg.icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 38px 0 34px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 14px/1 var(--sans);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:hover { border-color: var(--rule-strong); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-key {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  min-width: 20px; padding: 1px 6px; border: 1px solid var(--rule); border-radius: 3px;
  color: var(--muted); background: var(--paper); font: 12px/1.4 var(--mono); text-align: center;
}
.search input:focus ~ .search-key { visibility: hidden; }

.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  max-height: min(70vh, 520px); overflow: auto;
  padding: 6px; margin: 0;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(30, 28, 22, .12);
  list-style: none;
}
.search-results[hidden] { display: none; }
.search-results a {
  display: block; padding: 8px 10px; border-radius: 3px;
  color: var(--ink); text-decoration: none; line-height: 1.45;
}
.search-results a .r-title { display: block; font-weight: 600; font-size: 14px; }
.search-results a .r-page { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.search-results a .r-text { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--accent-wash); }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-results .r-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.search-results .r-hint { padding: 6px 10px 2px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--rule); margin-top: 4px; }

/* ------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 220px;
  max-width: 1360px; margin: 0 auto;
}

.sidebar {
  position: sticky; top: var(--topbar); align-self: start;
  height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 26px 18px 40px 22px;
  border-right: 1px solid var(--rule);
  font-size: 14.5px;
}
.sidebar h2 {
  margin: 22px 0 6px; padding: 0 10px;
  font: 600 12px/1.4 var(--sans); letter-spacing: .08em; color: var(--muted);
}
.sidebar h2:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block; padding: 5px 10px; margin: 1px 0;
  color: var(--ink-soft); text-decoration: none; border-radius: 3px;
  border-left: 2px solid transparent;
  transition: background-color .12s, color .12s;
}
.sidebar a:hover { background: var(--sunken); color: var(--ink); }
.sidebar a[aria-current="page"] {
  color: var(--accent-ink); background: var(--accent-wash);
  border-left-color: var(--accent); font-weight: 600;
}

.content { min-width: 0; padding: 30px 56px 64px; }
article { max-width: 760px; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs span[aria-hidden] { margin: 0 7px; color: var(--rule-strong); }

h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); line-height: 1.35; font-weight: 600; }
h1 { font-size: 32px; margin: 0 0 10px; letter-spacing: .01em; }
h2 { font-size: 23px; margin: 46px 0 12px; padding-top: 4px; }
h3 { font-size: 18.5px; margin: 32px 0 8px; }
h4 { font-size: 16px; margin: 24px 0 6px; font-family: var(--sans); }
h2 .anchor, h3 .anchor {
  margin-left: 8px; color: var(--rule-strong); text-decoration: none;
  font-family: var(--sans); font-weight: 400; opacity: 0; transition: opacity .12s;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); }

.lede { font-size: 17.5px; color: var(--ink-soft); margin: 4px 0 12px; }
.meta { font-size: 13px; color: var(--muted); margin: 0 0 28px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }

p { margin: 0 0 14px; }
ul, ol { margin: 0 0 16px; padding-left: 1.4em; }
li { margin: 4px 0; }
li > ul, li > ol { margin: 4px 0 6px; }
strong { font-weight: 600; color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 36px 0; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }

code, kbd, samp { font-family: var(--mono); font-size: .88em; }
:not(pre) > code {
  padding: 1px 5px; border-radius: 3px;
  background: var(--code-bg); color: var(--ink);
  border: 1px solid var(--rule);
}
kbd {
  padding: 1px 6px; border: 1px solid var(--rule-strong); border-bottom-width: 2px;
  border-radius: 3px; background: var(--surface); font-size: .82em;
}

.code {
  position: relative; margin: 0 0 18px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--code-bg);
}
.code .code-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px 5px 12px; border-bottom: 1px solid var(--rule);
  font: 12px/1.4 var(--sans); color: var(--muted);
}
pre {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  font: 13.5px/1.6 var(--mono); color: var(--ink); tab-size: 4;
}
pre code { font-size: inherit; }
pre .c { color: var(--muted); }
pre .p { color: var(--accent); user-select: none; }
pre .h { background: var(--mark); border-radius: 2px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 3px;
  background: transparent; color: var(--muted);
  font: 12px/1 var(--sans); cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s;
}
.copy-btn svg.icon { width: 14px; height: 14px; }
.copy-btn:hover { background: var(--surface); border-color: var(--rule); color: var(--ink); }
.copy-btn.done { color: var(--accent); }

/* Notes and figures */

.note, .warn, .aside {
  margin: 0 0 18px; padding: 12px 16px;
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-wash);
}
.warn { border-left-color: var(--brick); background: var(--brick-wash); }
.aside { border-left-color: var(--ochre); background: var(--ochre-wash); }
.note p:last-child, .warn p:last-child, .aside p:last-child { margin-bottom: 0; }
.note .label, .warn .label, .aside .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }

figure { margin: 6px 0 22px; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }

.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.55; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
thead th { font-weight: 600; font-size: 13px; color: var(--muted); background: var(--sunken); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-wash) 55%, transparent); }
td code { white-space: nowrap; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.filter {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 10px;
}
.filter input {
  flex: 0 1 280px; height: 34px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: 14px var(--sans);
}
.filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.filter .count { font-size: 13px; color: var(--muted); }
tr.filtered-out { display: none; }

dl.terms dt { font-weight: 600; margin-top: 14px; }
dl.terms dd { margin: 2px 0 0 0; color: var(--ink-soft); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 28px; }
.path-list { list-style: none; padding: 0; margin: 0 0 20px; border-top: 1px solid var(--rule); }
.path-list li { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.path-list .who { display: block; font-weight: 600; }
.path-list .route { display: block; color: var(--ink-soft); font-size: 15px; }

.changes { list-style: none; padding: 0; margin: 0 0 20px; }
.changes li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--rule); margin: 0; }
.changes time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }

/* Tools */

.tool {
  margin: 8px 0 24px; padding: 16px 18px 18px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface);
}
.tool > h3:first-child, .tool > h4:first-child { margin-top: 0; }
.tool .row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 12px; }
.tool label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.tool label.check { flex-direction: row; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 14px; padding-bottom: 6px; }
.tool input[type="text"], .tool input[type="number"], .tool select, .tool textarea {
  height: 34px; padding: 0 9px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: 14px var(--mono);
}
.tool textarea { height: auto; min-height: 76px; padding: 8px 9px; width: 100%; resize: vertical; line-height: 1.5; }
.tool input:focus, .tool select:focus, .tool textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.tool input[aria-invalid="true"], .tool textarea[aria-invalid="true"] { border-color: var(--brick); }
.tool input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--paper);
  font: 500 14px/1 var(--sans); cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn.quiet { background: transparent; color: var(--accent); }
.btn.quiet:hover { background: var(--accent-wash); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.tool .out { margin-top: 4px; }
.tool .out dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.tool .out dt { color: var(--muted); }
.tool .out dd { margin: 0; font-family: var(--mono); font-size: 13.5px; word-break: break-all; }
.tool .status { min-height: 1.5em; font-size: 13.5px; color: var(--muted); margin: 6px 0 0; }
.tool .status.error { color: var(--brick); }
.tool .status.ok { color: var(--accent); }

.stepper .diagram { width: 100%; height: auto; display: block; margin: 4px 0 10px; }
.stepper .diagram .node rect { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 1.2; }
.stepper .diagram .node text { fill: var(--ink); font: 13px var(--sans); }
.stepper .diagram .node .sub { fill: var(--muted); font-size: 11px; }
.stepper .diagram .node.on rect { stroke: var(--accent); stroke-width: 2; fill: var(--accent-wash); }
.stepper .diagram .edge { stroke: var(--rule-strong); stroke-width: 1.4; fill: none; marker-end: url(#arrow-dim); }
.stepper .diagram .edge.on { stroke: var(--accent); stroke-width: 2.2; marker-end: url(#arrow-on); }
.stepper .diagram .edge.done { stroke: var(--muted); }
.stepper .diagram marker path { stroke: none; }
.stepper .diagram #arrow-dim path { fill: var(--rule-strong); }
.stepper .diagram #arrow-on path { fill: var(--accent); }
.stepper .diagram .tag { fill: var(--muted); font: 11px var(--mono); }
.stepper .diagram .tag.on { fill: var(--accent-ink); font-weight: 600; }
.stepper .controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper .counter { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stepper .explain { margin: 10px 0 0; padding: 10px 14px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); min-height: 5.5em; }
.stepper .explain p { margin: 0 0 6px; }
.stepper .explain p:last-child { margin: 0; }

.bits { font: 13px/1.45 var(--mono); overflow-x: auto; }

/* ------------------------------------------------------------ toc and pager */

.toc {
  position: sticky; top: var(--topbar); align-self: start;
  max-height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 30px 20px 30px 8px; font-size: 13px;
}
.toc-title { font-weight: 600; color: var(--muted); letter-spacing: .06em; font-size: 12px; margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: 3px 0 3px 12px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; line-height: 1.45;
}
.toc li.l3 a { padding-left: 24px; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--accent-ink); border-left-color: var(--accent); }

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  max-width: 760px; margin: 56px 0 0; padding-top: 22px; border-top: 1px solid var(--rule);
}
.pager a {
  display: block; padding: 12px 14px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.pager a:hover { border-color: var(--accent); background: var(--surface); }
.pager .dir { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.pager .next { text-align: right; grid-column: 2; }

.site-foot {
  max-width: 760px; margin-top: 40px; padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 13px; color: var(--muted);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

.scrim { position: fixed; inset: var(--topbar) 0 0 0; z-index: 18; background: rgba(20, 20, 16, .35); }
.scrim[hidden] { display: none; }

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 28px 40px 56px; }
}

@media (max-width: 860px) {
  :root { --topbar: 54px; }
  .layout { display: block; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand small { display: none; }
  .search { margin-left: 4px; flex: 1 1 auto; }
  .search-key { display: none; }
  .theme-btn span { display: none; }
  .theme-btn { width: 34px; padding: 0; margin-left: 0; }
  .sidebar {
    position: fixed; top: var(--topbar); left: 0; bottom: 0; z-index: 20;
    width: min(300px, 86vw); height: auto;
    background: var(--paper); border-right: 1px solid var(--rule-strong);
    transform: translateX(-102%); transition: transform .2s ease-out;
    visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .content { padding: 22px 16px 48px; }
  h1 { font-size: 27px; }
  h2 { font-size: 21px; margin-top: 38px; }
  .lede { font-size: 16.5px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .changes li { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .copy-btn, .tool, .scrim { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  a { color: inherit; }
}
