/* Ferroma docs site — "夜航邮路 × 信纸" dual theme. No external fonts, no dependencies. */

:root, [data-theme="dark"] {
  --bg: #0b111e;
  --bg-raise: #101828;
  --panel: #0e1626;
  --text: #dfe7f2;
  --muted: #8d9ab0;
  --faint: #5d6b82;
  --accent: #f2683c;
  --accent-soft: rgba(242, 104, 60, .14);
  --accent-line: rgba(242, 104, 60, .45);
  --border: #1d2941;
  --border-soft: #16203a;
  --code-bg: #0a1220;
  --code-border: #1a2740;
  --mark: rgba(242, 104, 60, .28);
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --c-com: #5d6f8a; --c-str: #9ece6a; --c-kw: #f2683c; --c-num: #e0af68;
  --c-typ: #7dcfff; --c-key: #7aa2f7; --c-var: #bb9af7; --c-flag: #e0af68;
}
[data-theme="light"] {
  --bg: #faf6ef;
  --bg-raise: #f4eee2;
  --panel: #fffdf8;
  --text: #232a35;
  --muted: #6b6250;
  --faint: #998f7c;
  --accent: #d1481c;
  --accent-soft: rgba(209, 72, 28, .10);
  --accent-line: rgba(209, 72, 28, .4);
  --border: #e5dcc9;
  --border-soft: #ece4d4;
  --code-bg: #f4eee0;
  --code-border: #e5dcc6;
  --mark: rgba(209, 72, 28, .22);
  --shadow: 0 12px 40px rgba(90, 70, 40, .18);
  --c-com: #8a8272; --c-str: #48752a; --c-kw: #c2410c; --c-num: #a16207;
  --c-typ: #0e7490; --c-key: #1d4ed8; --c-var: #7c3aed; --c-flag: #a16207;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.75 "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--mark); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, pre, kbd {
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, "Sarasa Mono SC", "Microsoft YaHei Mono", monospace;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand-env { width: 22px; height: 22px; }
.brand-env rect, .brand-env path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand:hover .brand-env { animation: env-bounce .5s ease; }
@keyframes env-bounce { 40% { transform: rotate(-7deg) translateY(-1px); } }
.topbar-tag {
  font: 600 10.5px/1 "Cascadia Code", Consolas, monospace;
  color: var(--accent); border: 1px solid var(--accent-line);
  border-radius: 3px; padding: 3px 6px; letter-spacing: .12em; text-transform: uppercase;
  opacity: .9;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent-line); }
.iconbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
[data-theme="dark"] .i-sun, [data-theme="light"] .i-moon { display: none; }
.menu-btn { display: none; }
.menu-btn-ghost { width: 34px; }
.lang-switch {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--faint);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  transition: border-color .15s, color .15s;
}
.lang-switch:hover { text-decoration: none; border-color: var(--accent-line); color: var(--muted); }
.lang-switch .on { color: var(--accent); }
.lang-switch .sep { opacity: .5; }

/* ------------------------------------------------------------------ search */
.search { position: relative; flex: 1; max-width: 420px; }
.search-icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 15px; height: 15px; fill: none; stroke: var(--faint); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 33px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel); color: var(--text); font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::placeholder { color: var(--faint); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
.sr-item { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.sr-item:hover, .sr-item.sel { background: var(--accent-soft); text-decoration: none; }
.sr-item .sr-title { font-weight: 650; font-size: 13.5px; }
.sr-item .sr-head { color: var(--accent); font-size: 11.5px; margin-left: 6px; font-weight: 600; }
.sr-item .sr-snippet { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-item mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.sr-empty { padding: 14px; color: var(--faint); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------------ shell */
.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 220px;
  gap: 0; max-width: 1440px; margin: 0 auto;
  align-items: start;
}
.sidebar {
  position: sticky; top: 58px; height: calc(100vh - 58px);
  overflow-y: auto; padding: 26px 14px 40px 20px;
  border-right: 1px solid var(--border-soft);
}
.sidebar-inner { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-top: 18px; }
.nav-group-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 6px 12px;
}
.nav-link {
  position: relative; display: block;
  padding: 5.5px 12px; border-radius: 7px;
  color: var(--muted); font-size: 13.5px; line-height: 1.5;
  transition: color .12s, background .12s;
}
.nav-link:hover { color: var(--text); background: var(--bg-raise); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%; width: 3px;
  border-radius: 2px; background: var(--accent);
}
.sidebar-foot { margin: 26px 12px 0; font: 500 11px/1.6 Consolas, monospace; color: var(--faint); }
.scrim { display: none; }

/* ------------------------------------------------------------------ content */
.content { padding: 40px 48px 30px; min-width: 0; max-width: 860px; }
.kicker {
  font: 650 11px/1 "Cascadia Code", Consolas, monospace;
  color: var(--accent); letter-spacing: .16em; text-transform: uppercase;
  margin-bottom: 14px;
}
.content h1 {
  font-size: 33px; line-height: 1.25; letter-spacing: -.015em;
  margin: 0 0 22px; font-weight: 750;
}
.content h2 {
  font-size: 22.5px; letter-spacing: -.01em; margin: 44px 0 14px; padding-top: 14px;
  font-weight: 700; position: relative;
}
.content h2::before {
  content: ""; position: absolute; left: -48px; top: 20px; bottom: 8px; width: 3px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  border-radius: 2px;
}
.content h3 { font-size: 17.5px; margin: 30px 0 10px; font-weight: 700; }
.content h4 { font-size: 15px; margin: 24px 0 8px; font-weight: 700; color: var(--text); }
.content h5, .content h6 { font-size: 14px; margin: 20px 0 6px; }
h1 .anchor, h2 .anchor, h3 .anchor, h4 .anchor {
  opacity: 0; margin-left: 10px; font-weight: 400; color: var(--faint); font-size: .8em;
  transition: opacity .15s;
}
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: .8; }
.content p { margin: 12px 0; color: var(--text); }
.content li { margin: 4px 0; }
.content ul, .content ol { padding-left: 26px; margin: 10px 0; }
.content li > ul, .content li > ol { margin: 4px 0; }
.content hr { border: 0; border-top: 1px solid var(--border-soft); margin: 34px 0; }
.content blockquote {
  margin: 16px 0; padding: 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  color: var(--muted);
}
.content blockquote p { margin: 6px 0; color: var(--muted); }
.content blockquote strong { color: var(--text); }
p code, li code, td code, th code, h1 code, h2 code, h3 code, h4 code, blockquote code {
  font-size: .86em; padding: 2px 6px; border-radius: 6px;
  background: var(--code-bg); border: 1px solid var(--code-border);
  color: var(--text); white-space: nowrap;
}
h1 code, h2 code, h3 code, h4 code { font-size: .82em; }

/* tables */
.tablewrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; }
.content table { border-collapse: collapse; width: 100%; font-size: 13.5px; line-height: 1.55; }
.content th, .content td { padding: 9px 14px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.content thead th { background: var(--bg-raise); font-weight: 700; font-size: 12.5px; letter-spacing: .02em; white-space: nowrap; }
.content tbody tr:last-child td { border-bottom: 0; }
.content tbody tr { transition: background .1s; }
.content tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.content td code, .content th code { white-space: normal; }

/* code blocks */
.codeblock { position: relative; margin: 18px 0; }
.codeblock pre {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 12px;
  font-size: 13px; line-height: 1.65; tab-size: 4;
}
.codeblock pre code { background: none; border: 0; padding: 0; white-space: pre; }
.codeblock[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 8px; right: 40px; z-index: 2;
  font: 650 10px/1 "Cascadia Code", Consolas, monospace; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); border: 1px solid var(--code-border);
  padding: 4px 7px; border-radius: 5px; background: var(--panel);
  pointer-events: none;
}
.copy-btn {
  position: absolute; top: 7px; right: 8px; z-index: 2;
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--faint);
  cursor: pointer; opacity: 0; transition: opacity .15s, color .15s, border-color .15s;
  font-size: 13px; line-height: 1;
}
.codeblock:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--panel); }
.copy-btn.ok { color: #4cc38a; }
.c-com { color: var(--c-com); font-style: italic; }
.c-str { color: var(--c-str); }
.c-kw { color: var(--c-kw); font-weight: 600; }
.c-num { color: var(--c-num); }
.c-typ { color: var(--c-typ); }
.c-key { color: var(--c-key); }
.c-var { color: var(--c-var); }
.c-flag { color: var(--c-flag); }

/* ------------------------------------------------------------------ toc */
.tocpane { position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto; padding: 40px 20px 40px 8px; }
.toc-title { font: 700 10.5px/1 sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; }
.toc a { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; padding: 3.5px 0 3.5px 12px; border-left: 1px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.toc-l3 { padding-left: 26px; font-size: 12px; }
.toc a.here { color: var(--accent); border-left: 2px solid var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ pager & footer */
.pager { display: flex; justify-content: space-between; gap: 14px; margin: 52px 0 18px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; max-width: 46%;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); transition: border-color .15s, background .15s;
}
.pager a:hover { text-decoration: none; border-color: var(--accent-line); background: var(--accent-soft); }
.pager small { color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.pager b { font-size: 14px; font-weight: 650; }
.pager-prev { align-items: flex-start; }
.pager-next { align-items: flex-end; text-align: right; margin-left: auto; }
.pager > span { flex: 1; }
.footer { color: var(--faint); font-size: 12.5px; padding: 26px 0 34px; border-top: 1px solid var(--border-soft); }
.footer-home { text-align: center; padding: 34px 0 44px; }

/* ------------------------------------------------------------------ home */
.hero { padding: 68px 24px 30px; }
.hero-inner {
  max-width: 1180px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; align-items: center;
}
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.hero-badges span {
  font: 600 11px/1 "Cascadia Code", Consolas, monospace; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); border: 1px dashed var(--accent-line);
  padding: 5px 9px; border-radius: 6px;
}
.hero h1 {
  font-size: clamp(46px, 7vw, 74px); margin: 0 0 18px; line-height: 1;
  letter-spacing: -.03em; font-weight: 800;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 75%, var(--c-key));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-line-en { font-size: 16.5px; color: var(--text); margin: 0 0 10px; line-height: 1.7; }
.hero-line-zh { font-size: 14.5px; color: var(--muted); margin: 0; line-height: 1.85; }
.hero-cta { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; font-weight: 650; font-size: 14px;
  border: 1px solid var(--border); color: var(--text); background: var(--panel);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--accent-line); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 6px 22px var(--accent-soft);
}
.btn-primary:hover { box-shadow: 0 8px 26px var(--accent-line); }
.hero-ascii {
  margin: 0; padding: 18px; border-radius: 14px; position: relative;
  background: var(--panel); border: 1px dashed var(--accent-line);
  box-shadow: var(--shadow);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 50% { box-shadow: 0 14px 46px var(--accent-soft); } }
.hero-ascii::after {
  content: "RFC 5321 · 3501 · 9051"; position: absolute; right: 14px; bottom: 10px;
  font: 500 9.5px/1 Consolas, monospace; color: var(--faint); letter-spacing: .08em;
}
.hero-ascii pre {
  margin: 0; overflow-x: auto;
  font: 500 10.5px/1.35 "Cascadia Code", Consolas, monospace;
  color: var(--muted);
}
.section { max-width: 1180px; margin: 0 auto; padding: 40px 24px 8px; }
.section-title { font-size: 24px; letter-spacing: -.01em; margin: 0 0 22px; font-weight: 750; }
.section-title::after { content: ""; display: block; width: 44px; height: 3px; margin-top: 10px; border-radius: 2px; background: var(--accent); }
.section-note { color: var(--muted); font-size: 13.5px; }
.section-note a { color: var(--accent); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.feature {
  padding: 20px 22px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--panel); transition: border-color .15s, transform .15s;
}
.feature:hover { border-color: var(--accent-line); transform: translateY(-2px); }
.feature h3 { margin: 0; font-size: 16px; font-weight: 700; }
.feature-zh { color: var(--accent); font-size: 12.5px; font-weight: 600; margin: 3px 0 10px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.feature .feat-zh { margin-top: 6px; color: var(--faint); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.doc-card {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 18px 20px 16px; border: 1px solid var(--border); border-radius: 13px;
  background: var(--panel); color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.doc-card:hover { text-decoration: none; border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow); }
.doc-card-en { font-weight: 750; font-size: 15.5px; letter-spacing: -.01em; }
.doc-card-zh { color: var(--accent); font-size: 12.5px; font-weight: 650; }
.doc-card-desc { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin-top: 7px; }
.doc-card-glyph {
  position: absolute; right: 16px; top: 16px; color: var(--faint);
  transition: transform .15s, color .15s;
}
.doc-card:hover .doc-card-glyph { transform: translateX(3px); color: var(--accent); }
.hero-code { max-width: 720px; }
.hero-code pre { font-size: 12.5px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1240px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .tocpane { display: none; }
  .content h2::before { left: -20px; }
}
@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; gap: 30px; }
  .hero { padding-top: 40px; }
  .menu-btn { display: inline-flex; }
  .menu-btn-ghost { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; z-index: 80;
    width: 274px; background: var(--bg);
    transform: translateX(-102%); transition: transform .22s ease;
    border-right: 1px solid var(--border); box-shadow: var(--shadow);
    padding-top: 20px;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; }
  .content { padding: 30px 22px; }
  .topbar-tag { display: none; }
}
@media (max-width: 620px) {
  .search { max-width: none; }
  .lang-switch { padding: 7px 7px; }
  .content h1 { font-size: 26px; }
  .content h2::before { display: none; }
  .hero h1 { font-size: 44px; }
  .pager a { max-width: none; }
}
@media print {
  .topbar, .sidebar, .tocpane, .pager, .copy-btn, .scrim { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
}