:root {
  --primary: #174778;
  --primary-dark: #0f3258;
  --primary-light: #e8f0fe;
  --accent: #d9643a;
  --accent-hover: #bf532b;
  --text-main: #1c2736;
  --text-muted: #52637a;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-light: #e2e8f0;
  --border-card: #d0dbe7;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
}

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

html {
  font-size: 16px;
  color: var(--text-main);
  background-color: var(--bg-page);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header & Navigation */
header.site-header {
  height: var(--header-height);
  max-height: 72px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
}

.site-logo svg {
  width: 32px;
  height: 32px;
}

nav.main-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

nav.main-nav a {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  padding: 0 6px;
  height: 36px;
  line-height: 36px;
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  box-sizing: border-box;
}

nav.main-nav a:hover {
  color: var(--primary);
  border-bottom-color: var(--border-card);
}

nav.main-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  border-radius: var(--radius-sm);
}

.icon-btn:hover {
  background: var(--bg-page);
  color: var(--primary);
}

.menu-toggle {
  display: none;
}

/* Mobile Nav Drawer */
.mobile-nav-drawer {
  display: none;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 20px;
}

.mobile-nav-drawer.is-open {
  display: block;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mobile-nav-links a {
  font-size: 16px;
  padding: 8px 0;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

/* Search Overlay */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 35, 60, 0.6);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.search-overlay.is-open {
  display: flex;
}

.search-modal {
  background: #ffffff;
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 600px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.search-form {
  display: flex;
  gap: 10px;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.search-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0 8px;
}

/* Responsive navigation visibility */
@media (max-width: 1099px) {
  nav.main-nav {
    display: none;
  }
  .menu-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 17px;
  }
  .container {
    padding: 0 16px;
  }
}

/* Typography & Content Layout */
main {
  flex: 1;
}

h1, h2, h3, h4 {
  color: var(--primary-dark);
  line-height: 1.35;
  margin-bottom: 0.5em;
}

h1 { font-size: 32px; font-weight: 700; margin-bottom: 16px; word-break: break-word; }
h2 { font-size: 24px; font-weight: 700; margin-top: 36px; margin-bottom: 16px; }
h3 { font-size: 19px; font-weight: 600; margin-top: 24px; margin-bottom: 12px; }
h4 { font-size: 16px; font-weight: 600; margin-top: 18px; margin-bottom: 8px; }

p {
  margin-bottom: 1.1em;
  color: var(--text-main);
  text-align: justify;
}

main p a:not(.button) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

ul, ol {
  margin-bottom: 1.2em;
  padding-left: 24px;
}

li {
  margin-bottom: 0.4em;
}

/* Buttons */
.button, .btn-primary {
  display: inline-block;
  background-color: var(--accent);
  color: #ffffff !important;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease;
}

.button:hover, .btn-primary:hover {
  background-color: var(--accent-hover);
}

.button.outline, .btn-secondary {
  background: transparent;
  color: var(--primary) !important;
  border: 1px solid var(--primary);
}

.button.outline:hover, .btn-secondary:hover {
  background: var(--primary-light);
}

.hero-actions .button.outline,
.hero-scene .button.outline {
  background: rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  border: 1.5px solid rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(4px);
}

.hero-actions .button.outline:hover,
.hero-scene .button.outline:hover {
  background: rgba(255, 255, 255, 0.28) !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* Hero Section with Photo and Gradient Overlay */
.hero-scene {
  position: relative;
  min-height: 380px;
  background-color: var(--primary-dark);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 20px auto 40px;
  display: flex;
  align-items: center;
}

.hero-scene img.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.38;
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 40px 32px;
  max-width: 680px;
  color: #ffffff;
}

.hero-content h1 {
  color: #ffffff;
}

.hero-content p {
  color: #f1f5f9;
  font-size: 17px;
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* Cards & Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.card p {
  color: var(--text-muted);
  font-size: 15px;
  flex: 1;
}

.card .link {
  font-weight: 600;
  margin-top: 14px;
  display: inline-block;
  white-space: nowrap;
}

/* Article Page Layout */
.article-header {
  margin: 30px 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.article-meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
}

.article-lead {
  font-size: 18px;
  color: var(--primary-dark);
  font-weight: 500;
  line-height: 1.6;
  margin: 16px 0 24px;
  background: transparent !important;
  padding: 0 0 0 16px;
  border-left: 4px solid var(--primary);
  border-radius: 0;
}

/* Table of Contents & Article Layout */
.page-toc {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0 0 24px 0;
}

.page-toc .toc-title,
.page-toc .page-toc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.page-toc-toggle-btn {
  display: none;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
}

.page-toc-toggle-btn .toc-arrow {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.page-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-toc li {
  margin-bottom: 4px;
  padding: 0;
}

.page-toc a {
  display: block;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  line-height: 1.45;
}

.page-toc a:hover {
  color: var(--primary);
  background: var(--bg-alt);
}

.page-toc a.active {
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
  background: #eff6ff;
}

/* Article Layout: Main Content & Sticky Sidebar */
@media (min-width: 1200px) {
  .article-layout {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: flex-start;
  }
  .article-main {
    flex: 1 1 0;
    min-width: 0;
    max-width: 820px;
  }
  .article-main p,
  .article-main li {
    max-width: 38em;
  }
  .article-sidebar {
    flex: 0 0 280px;
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
  .article-sidebar .page-toc {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }
  .page-toc-toggle-btn {
    display: none !important;
  }
  .page-toc-body {
    display: block !important;
  }
}

@media (max-width: 1199px) {
  .article-layout {
    display: flex;
    flex-direction: column;
  }
  .article-sidebar {
    order: -1;
    margin-bottom: 24px;
    width: 100%;
  }
  .page-toc {
    padding: 0;
    border: none;
    background: transparent;
  }
  .page-toc .toc-title,
  .page-toc .page-toc-title {
    display: none;
  }
  .page-toc-toggle-btn {
    display: flex;
  }
  .page-toc-body {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
  }
  .page-toc.is-expanded .page-toc-body {
    display: block;
  }
  .page-toc.is-expanded .page-toc-toggle-btn .toc-arrow {
    transform: rotate(180deg);
  }
}

.breadcrumbs {
  font-size: 14px;
  color: var(--text-muted);
  margin: 14px 0;
  white-space: nowrap;
  overflow-x: auto;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs span {
  margin: 0 6px;
}

/* Callouts */
.callout {
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  margin: 20px 0;
  border-left: 4px solid;
}

.callout.info {
  background: #f0f7ff;
  border-color: var(--primary);
}

.callout.alert {
  background: #fff5f2;
  border-color: var(--accent);
}

.callout h4 {
  margin-top: 0;
  margin-bottom: 6px;
}

/* Tables (responsive to cards on small screens) */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

table.data-table th, table.data-table td {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  text-align: left;
}

table.data-table th {
  background: #edf2f7;
  color: var(--primary-dark);
  font-weight: 600;
}

table.data-table tr:nth-child(even) td {
  background: #fbfcfe;
}

@media (max-width: 600px) {
  table.responsive-card, table.responsive-card thead, table.responsive-card tbody, table.responsive-card th, table.responsive-card td, table.responsive-card tr {
    display: block;
  }
  table.responsive-card thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  table.responsive-card tr {
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    background: #fff;
    padding: 10px;
  }
  table.responsive-card td {
    border: none;
    padding: 6px 0;
    position: relative;
    padding-left: 42%;
  }
  table.responsive-card td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 38%;
    font-weight: 600;
    color: var(--primary-dark);
  }
}

/* FAQ Details Accordion */
.faq-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #ffffff;
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-question {
  padding: 14px 18px;
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 20px;
  color: var(--text-muted);
}

details[open] .faq-question::after {
  content: "−";
}

.faq-answer {
  padding: 0 18px 16px;
  color: var(--text-main);
  font-size: 15px;
}

/* Reference Citations */
sup.citation {
  font-size: 12px;
  padding: 0 2px;
}

.references-section {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}

.references-section ol {
  font-size: 14px;
  color: var(--text-muted);
}

.references-section li {
  margin-bottom: 8px;
}

/* Search Results Styling */
.search-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.search-result-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(23, 71, 120, 0.08);
}

.search-result-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.search-result-title a {
  color: var(--primary);
  text-decoration: none;
}

.search-result-title a:hover {
  color: var(--accent);
}

.search-result-snippet {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.search-highlight {
  background: #fef08a;
  color: #854d0e;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 600;
}

/* Term Popover / Bottom Sheet Modal */
.term-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.term-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.term-modal-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  max-width: 480px;
  width: 90%;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.term-modal-overlay.is-open .term-modal-card {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .term-modal-overlay {
    align-items: flex-end;
  }
  .term-modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 20px 20px 32px;
  }
}

/* Footer */
footer.site-footer {
  background: #0d2138;
  color: #cbd5e1;
  margin-top: 60px;
  padding: 48px 0 32px;
  font-size: 14px;
}

footer.site-footer a {
  color: #93c5fd;
}

footer.site-footer a:hover {
  color: #ffffff;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
  margin-bottom: 36px;
}

.footer-col .footer-title {
  color: #ffffff;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 600;
}

.footer-col ul {
  list-style: none;
  padding: 0;
}

.footer-col li {
  margin-bottom: 8px;
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 24px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.site-footer p {
  color: #cbd5e1;
}

/* Defect Interactive Map Widget */
.defect-map-widget {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 32px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.defect-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.defect-tab-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-card);
  background: #f8fafc;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.defect-tab-btn:hover {
  background: #e2e8f0;
}

.defect-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.defect-interactive-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 860px) {
  .defect-interactive-layout {
    grid-template-columns: 1fr;
  }
}

.defect-map-figure {
  margin: 0;
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.defect-map-figure svg {
  width: 100%;
  height: auto;
  display: block;
}

.defect-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.defect-panel.active {
  display: block;
}

.defect-panel h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 20px;
  color: var(--primary);
}

.defect-panel p {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--text-main);
}

.defect-spot {
  transition: transform 0.2s, opacity 0.2s;
}

.defect-spot:hover, .defect-spot.is-highlight {
  filter: drop-shadow(0 0 8px rgba(217, 100, 58, 0.8));
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Print Style */
@media print {
  header.site-header, footer.site-footer, .button, .btn-primary, .btn-secondary, .search-overlay, .menu-toggle {
    display: none !important;
  }
  body {
    background: #ffffff;
    color: #000000;
  }
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 11px;
  }
}
