:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --ink: #15171a;
  --muted: #5f6b7a;
  --soft: #eef2f6;
  --border: #d9e0ea;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --amber: #a15c12;
  --rose: #9f1239;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  padding: 0.12rem 0.34rem;
  border: 1px solid #d7dfeb;
  border-radius: 6px;
  background: #f4f7fb;
  color: #1f2937;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  min-width: 0;
  color: var(--ink);
  font-weight: 750;
}

.brand span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 800;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.topbar-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-subtle);
}

.doc-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr) 254px;
  gap: 28px;
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 26px 28px 56px;
}

.sidebar,
.toc {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.sidebar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-head label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.doc-search {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cfd8e4;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font: 500 14px/1.4 var(--font-sans);
  outline: none;
}

.doc-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.nav-list {
  padding: 10px 0 14px;
}

.nav-group {
  margin: 0;
  padding: 10px 12px;
}

.nav-group h2 {
  margin: 0 0 6px;
  padding: 0 8px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.nav-link {
  display: block;
  margin: 2px 0;
  border-left: 3px solid transparent;
  border-radius: 0 7px 7px 0;
  padding: 8px 8px 8px 10px;
  color: #1f2937;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.nav-link span {
  display: block;
  margin-bottom: 2px;
  color: #64748b;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.nav-link:hover {
  background: #f2f6f8;
  text-decoration: none;
}

.nav-link.active {
  border-left-color: var(--accent);
  background: #eaf6f4;
  color: #0f3f3b;
}

.article {
  min-width: 0;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 760;
}

.breadcrumb::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 6px;
  background: currentColor;
  clip-path: polygon(54% 15%, 62% 23%, 38% 47%, 86% 47%, 86% 59%, 38% 59%, 62% 83%, 54% 91%, 16% 53%);
}

.doc-header,
.overview-hero,
.content-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.doc-header,
.overview-hero {
  padding: 32px;
}

.doc-code {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  max-width: 780px;
  margin: 0;
  color: #101418;
  font-size: 38px;
  line-height: 1.18;
  font-weight: 820;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lede {
  max-width: 860px;
  margin: 18px 0 0;
  color: #405066;
  font-size: 18px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.doc-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.doc-fields div {
  min-width: 0;
  border: 1px solid #dce3ec;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
}

.doc-fields span {
  display: block;
  margin-bottom: 4px;
  color: #667085;
  font-size: 12px;
  font-weight: 750;
}

.doc-fields strong {
  display: block;
  color: #111827;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.overview-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.prose {
  max-width: 780px;
  margin: 22px auto 0;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.prose h2,
.content-section h2 {
  margin: 0 0 14px;
  color: #111827;
  font-size: 25px;
  line-height: 1.3;
  font-weight: 810;
}

.heading-anchor {
  margin-left: 8px;
  color: #94a3b8;
  font-size: 0.72em;
  font-weight: 750;
  opacity: 0;
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.prose h2 {
  scroll-margin-top: 92px;
  margin-top: 32px;
  padding-top: 4px;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose h3 {
  scroll-margin-top: 92px;
  margin: 26px 0 10px;
  color: #1f2937;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 780;
}

.prose h4 {
  margin: 22px 0 8px;
  color: #273449;
  font-size: 17px;
  font-weight: 780;
}

.prose p,
.prose li,
.content-section p {
  color: #344154;
}

.prose p {
  margin: 0 0 14px;
}

.prose ol,
.prose ul {
  margin: 0 0 18px;
  padding-left: 1.35rem;
}

.prose li + li {
  margin-top: 6px;
}

.content-section {
  margin-top: 22px;
  padding: 30px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-heading h2,
.warning-section h2 {
  flex: 0 0 auto;
}

.section-heading p {
  max-width: 640px;
  margin: 0;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.pillar-card {
  min-width: 0;
  border: 1px solid #dce3ec;
  border-radius: var(--radius);
  padding: 18px;
  background: #f8fafc;
}

.pillar-index {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 850;
}

.pillar-card h3 {
  min-height: 48px;
  margin: 0 0 10px;
  color: #111827;
  font-size: 17px;
  line-height: 1.35;
}

.pillar-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

.visual-section {
  overflow: hidden;
}

.governance-map {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: #f4f7fb;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-list a {
  border: 1px solid #d2dbe7;
  border-radius: 999px;
  padding: 8px 12px;
  background: #f8fafc;
  color: #203247;
  font-size: 14px;
  font-weight: 720;
}

.source-list a:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  text-decoration: none;
}

.warning-section {
  border-color: #f0d7b2;
  background: #fffaf3;
}

.warning-section h2 {
  color: #7a3f05;
}

.warning-section p {
  max-width: 940px;
  margin: 0;
  color: #53340e;
  font-weight: 650;
}

.policy-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.policy-list article {
  border: 1px solid #dce3ec;
  border-radius: var(--radius);
  padding: 16px;
  background: #f8fafc;
}

.policy-list p {
  margin: 0;
  color: #273449;
  font-size: 14px;
  line-height: 1.65;
  font-weight: 620;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.artifact-grid a {
  display: grid;
  gap: 6px;
  min-height: 118px;
  border: 1px solid #c8d7e5;
  border-radius: var(--radius);
  padding: 18px;
  background: #f8fafc;
  color: #172033;
}

.artifact-grid a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.artifact-grid strong {
  color: #0f5f59;
  font-family: var(--font-mono);
  font-size: 15px;
}

.artifact-grid span {
  color: #536173;
  font-size: 14px;
  line-height: 1.55;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f5f9;
  color: #243247;
  font-size: 12px;
  font-weight: 850;
}

td {
  color: #334155;
}

tr:last-child td {
  border-bottom: 0;
}

.document-table th:nth-child(1),
.document-table td:nth-child(1) {
  width: 150px;
}

.document-table th:nth-child(5),
.document-table td:nth-child(5) {
  width: 92px;
}

.table-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid #b7d7d4;
  border-radius: 7px;
  padding: 5px 10px;
  color: #0f5f59;
  background: #eefaf8;
  font-size: 13px;
  font-weight: 800;
}

.table-action::after {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(20% 13%, 87% 13%, 87% 80%, 73% 80%, 73% 38%, 27% 84%, 16% 73%, 62% 27%, 20% 27%);
}

.table-action:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.toc {
  display: grid;
  gap: 14px;
}

.side-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.side-panel h2 {
  margin: 0 0 12px;
  color: #111827;
  font-size: 13px;
  font-weight: 850;
}

.side-panel dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.side-panel dl div {
  display: grid;
  gap: 2px;
}

.side-panel dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 760;
}

.side-panel dd {
  margin: 0;
  color: #1f2937;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.policy-panel p {
  margin: 0;
  color: #3f4c5f;
  font-size: 13px;
  line-height: 1.55;
}

.toc-list {
  display: grid;
  gap: 4px;
}

.toc-link {
  border-left: 2px solid transparent;
  padding: 6px 0 6px 10px;
  color: #536173;
  font-size: 13px;
  line-height: 1.35;
}

.toc-link.level-3 {
  padding-left: 20px;
  font-size: 12px;
}

.toc-link:hover,
.toc-link.active {
  border-left-color: var(--accent);
  color: #0f5f59;
  text-decoration: none;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 780px;
  margin: 18px auto 0;
}

.pager a {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
  color: #1f2937;
  font-weight: 760;
  line-height: 1.45;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.pager a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.pager span {
  display: block;
  margin-bottom: 3px;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

.hidden-by-search {
  display: none;
}

@media (max-width: 1240px) {
  .doc-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .pillar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .doc-shell {
    display: flex;
    flex-direction: column;
    padding: 18px;
  }

  .article {
    order: 1;
  }

  .sidebar {
    order: 2;
    position: relative;
    top: auto;
    max-height: none;
    margin-top: 18px;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
  }

  .doc-header,
  .overview-hero,
  .content-section,
  .prose {
    padding: 22px;
  }

  h1 {
    font-size: 31px;
  }

  .doc-fields,
  .overview-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-heading {
    display: block;
  }

  .section-heading p {
    margin-top: 8px;
  }
}

@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .doc-shell {
    width: 100vw;
    padding-right: 18px;
    padding-left: 18px;
  }

  .article {
    width: calc(100vw - 36px);
    max-width: calc(100vw - 36px);
  }

  .topbar,
  .doc-header,
  .overview-hero,
  .content-section,
  .prose {
    width: 100%;
    max-width: 100%;
  }

  .doc-shell {
    margin: 0;
    overflow-x: hidden;
  }

  .doc-header,
  .overview-hero,
  .content-section,
  .prose {
    overflow: hidden;
  }

  .topbar-meta {
    justify-content: flex-start;
  }

  .nav-list,
  .pillar-grid,
  .artifact-grid,
  .doc-fields,
  .overview-fields,
  .pager {
    grid-template-columns: 1fr;
  }

  .doc-header,
  .overview-hero,
  .content-section,
  .prose {
    padding: 18px;
  }

  h1 {
    font-size: 28px;
    word-break: break-all;
  }

  .lede {
    font-size: 16px;
    word-break: break-all;
  }

  .doc-fields strong,
  .content-section p,
  .prose p,
  .prose li,
  .nav-link {
    word-break: break-all;
  }

  .governance-map {
    min-width: 720px;
  }

  .visual-section {
    overflow-x: auto;
  }
}
