:root {
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f0f6f4;
  --surface-alt: #f7f9fc;
  --ink: #172326;
  --muted: #5a6872;
  --line: #d7e0e6;
  --accent: #087669;
  --accent-strong: #064f49;
  --accent-secondary: #405f9b;
  --warning: #946200;
  --code: #152026;
  --shadow: 0 12px 32px rgba(20, 31, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family:
    "Segoe UI Variable Text", "Segoe UI", "Noto Sans TC", "PingFang TC",
    sans-serif;
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(64, 95, 155, 0.42);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  transform: translateY(-160%);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 850;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.layout-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--line);
  background: #f8fbfd;
  overflow-y: auto;
}

.sidebar-close {
  display: none;
  margin: 0 0 0.9rem auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  padding: 0.5rem 0.72rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(23, 35, 38, 0.38);
}

.noscript-note {
  margin: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.brand-block h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.15;
}

.eyebrow,
.page-kicker,
.hero-kicker,
.search-label,
.nav-section-title,
.outline-title {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.tagline,
.sidebar-note,
.summary-band p,
.page-kicker {
  color: var(--muted);
  line-height: 1.55;
}

.lang-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem;
  margin: 1rem 0 1.1rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lang-option {
  min-height: 2.25rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.lang-option:hover,
.lang-option:focus-visible {
  background: var(--surface-muted);
  color: var(--ink);
}

.lang-option.active {
  background: var(--accent);
  color: #ffffff;
}

.nav-filter {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.72rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.page-nav {
  display: grid;
  gap: 0.5rem;
}

.nav-section {
  display: grid;
  gap: 0.35rem;
}

.nav-section + .nav-section {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.page-link {
  display: block;
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
}

.page-link:hover,
.page-link:focus-visible {
  border-color: var(--line);
  background: var(--surface);
}

.page-link.active {
  border-color: rgba(8, 118, 105, 0.32);
  background: var(--surface-muted);
}

.page-link strong {
  display: block;
  margin-bottom: 0.15rem;
}

.page-link span {
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.35;
}

.nav-empty {
  margin: 0;
  padding: 0.85rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-note {
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.content-shell {
  padding: 1.35rem clamp(1rem, 3vw, 2.4rem) 4rem;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.topbar > div {
  min-width: 0;
  flex: 1;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 0.62rem 0.9rem;
  font: inherit;
}

.page-title {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.18;
}

.summary-band {
  display: none;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 1rem;
  align-items: stretch;
  min-width: 0;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-result-count {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.page-hit {
  display: block;
  margin-top: 0.24rem;
  color: var(--accent-secondary);
  font-size: 0.82rem;
}

body.overview-doc-page .summary-band:not([hidden]) {
  display: grid;
}

.summary-band p {
  margin: 0;
  overflow-wrap: anywhere;
}

.summary-band > *,
.hero-metrics > *,
.status-strip > * {
  min-width: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.hero-actions a {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 2.25rem;
  padding: 0.45rem 0.72rem;
  border: 1px solid rgba(8, 118, 105, 0.26);
  border-radius: 8px;
  background: #f3fbf9;
  color: var(--accent-strong);
  font-size: 0.93rem;
  font-weight: 800;
  text-decoration: none;
}

.hero-actions a:hover,
.hero-actions a:focus-visible {
  border-color: var(--accent);
  background: #e7f5f2;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
}

.hero-metrics div {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.hero-metrics dt {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.hero-metrics dd {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-strip {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

body.overview-doc-page .status-strip:not([hidden]) {
  display: grid;
}

.status-strip div {
  min-width: 0;
  padding: 0.72rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-strip span,
.status-strip strong {
  display: block;
}

.status-strip span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-strip strong {
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 270px);
  gap: 1rem;
  align-items: start;
}

.doc-content {
  padding: clamp(1rem, 2vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  line-height: 1.72;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.doc-content h1 {
  margin-top: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.16;
}

.doc-content h2,
.doc-content h3 {
  scroll-margin-top: 1.25rem;
}

.doc-content h2 {
  margin-top: 1.8rem;
}

.doc-content h3 {
  margin-top: 1.2rem;
}

.doc-content img {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 520px);
  height: auto;
  margin: 1rem auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.path-grid,
.principle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.35rem;
}

.path-card,
.principle-card {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.path-card h3,
.principle-card h3 {
  margin: 0.25rem 0 0.45rem;
  font-size: 1.05rem;
  line-height: 1.25;
}

.path-card p,
.principle-card p {
  margin: 0.45rem 0 0;
}

.path-card a,
.principle-card a {
  font-weight: 800;
}

.card-kicker {
  margin: 0;
  color: var(--accent-secondary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table-scroll {
  margin: 1.1rem 0;
  overflow-x: auto;
}

.table-scroll table {
  margin: 0;
  min-width: 640px;
}

.doc-content th,
.doc-content td {
  padding: 0.62rem 0.7rem;
  border: 1px solid var(--line);
  vertical-align: top;
}

.doc-content th {
  background: var(--surface-muted);
}

.doc-content pre,
.doc-content code {
  font-family: Consolas, "Cascadia Mono", "SFMono-Regular", monospace;
}

.doc-content pre {
  padding: 1rem;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--code);
  color: #f8fafc;
}

.doc-content :not(pre) > code {
  padding: 0.1rem 0.32rem;
  border-radius: 6px;
  background: rgba(8, 118, 105, 0.08);
}

.doc-content blockquote {
  margin: 1rem 0;
  padding: 0.3rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-muted);
}

.doc-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.mermaid-shell {
  margin: 1rem 0;
  padding: 0.9rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.page-outline {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.outline-panel {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.outline-nav {
  display: grid;
  gap: 0.3rem;
}

.outline-link {
  color: var(--ink);
  text-decoration: none;
  line-height: 1.42;
  padding: 0.25rem 0;
}

.outline-link.h3 {
  padding-left: 0.9rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.outline-link:hover,
.outline-link:focus-visible {
  color: var(--accent);
}

@media (max-width: 1180px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .page-outline {
    position: static;
    order: -1;
    max-height: 16rem;
  }
}

@media (max-width: 960px) {
  .layout-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 320px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 10;
  }

  .sidebar-close {
    display: block;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .summary-band {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 540px) {
  .content-shell {
    padding-inline: 0.75rem;
  }

  .topbar {
    display: block;
  }

  .nav-toggle {
    margin-bottom: 0.7rem;
  }

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

  .hero-actions a {
    justify-content: center;
    text-align: center;
  }

  .hero-metrics {
    gap: 0.45rem;
  }

  .hero-metrics div {
    padding: 0.55rem;
  }

  .hero-metrics dt {
    font-size: 1.05rem;
  }

  .hero-metrics dd {
    font-size: 0.72rem;
  }

  .doc-content,
  .summary-band {
    padding: 0.85rem;
  }

  .summary-band {
    max-width: calc(100vw - 1.5rem);
  }

  body.overview-doc-page .status-strip:not([hidden]) {
    display: none;
  }

  .page-kicker,
  #hero-copy,
  .hero-actions,
  .hero-metrics,
  .status-strip {
    max-width: calc(100vw - 3rem);
  }

  .summary-band p {
    word-break: break-word;
  }

  .page-title {
    font-size: 1.55rem;
  }
}
