:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --accent: #0284c7;
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --border: #e5e7eb;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --success: #059669;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
}

/* Navbar */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--primary);
}

/* Search Box */
.nav-search {
  position: relative;
  width: 320px;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: #f1f5f9;
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  background: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 450px;
  max-height: 500px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.search-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  display: block;
  color: var(--text-main);
  transition: background 0.15s;
}

.search-result-item:hover {
  background: var(--primary-bg);
}

.search-result-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary);
}

.search-result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, #1e3a8a 0%, #0369a1 100%);
  color: #fff;
  padding: 3rem 1.5rem;
  text-align: center;
}

.hero-content h1 {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Home Columns */
.columns-container {
  max-width: 1100px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.section-title {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
  font-weight: 700;
}

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

.column-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.column-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.06);
  border-color: var(--primary-light);
}

.card-badge {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: #dcfce7;
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
}

.card-badge.secondary {
  background: #f1f5f9;
  color: var(--text-muted);
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.card-body h3 {
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.card-desc {
  font-size: 0.925rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.75rem;
}

.card-action {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

/* Directory Page */
.directory-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

.directory-header h1 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.directory-intro {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.directory-tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.tab-btn {
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab-btn:hover, .tab-btn.active {
  background: var(--primary-bg);
  color: var(--primary);
}

.category-heading {
  font-size: 1.35rem;
  color: var(--primary);
  margin: 2.5rem 0 1rem;
  padding-left: 0.5rem;
  border-left: 4px solid var(--primary);
}

.directory-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.dir-row {
  display: flex;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  gap: 1.5rem;
  transition: background 0.15s;
}

.dir-row:last-child {
  border-bottom: none;
}

.dir-row:hover {
  background: #f8fafc;
}

.dir-main {
  width: 320px;
  flex-shrink: 0;
}

.dir-title {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  gap: 0.2rem;
}

.part-badge {
  align-self: flex-start;
  font-size: 0.75rem;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
}

.title-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.title-en {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.dir-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.dir-summary {
  flex-grow: 1;
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.summary-label {
  font-weight: 600;
  color: var(--text-main);
}

.dir-arrow {
  flex-shrink: 0;
}

.enter-btn {
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  transition: all 0.2s;
  white-space: nowrap;
}

.enter-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Section Article Layout */
.article-layout {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 2rem;
}

.left-sidebar .sticky-box,
.right-sidebar .sticky-box {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sidebar-header h4 {
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.toc-nav ul {
  list-style: none;
}

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

.toc-nav li {
  margin-bottom: 0.35rem;
}

.toc-nav a {
  text-decoration: none;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 500;
  display: block;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.toc-nav a:hover {
  color: var(--primary);
  background: #f1f5f9;
}

.sidebar-meta {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid #f1f5f9;
  padding-top: 0.75rem;
}

.article-main {
  background: var(--bg-card);
  padding: 2.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  min-width: 0;
}

.article-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.article-title {
  font-size: 2rem;
  color: var(--primary);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.article-subtitle-en {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.article-tags {
  display: flex;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-muted);
}

.badge-success {
  background: #dcfce7;
  color: var(--success);
  font-weight: 600;
}

.badge-warning {
  background: #fef3c7;
  color: #d97706;
}

.article-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #27272a;
}

.section-h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin: 2rem 0 0.75rem;
  padding: 0.15rem 0 0.15rem 0.6rem;
  border-left: 3px solid var(--accent);
  border-bottom: none;
  background: #f8fafc;
  border-radius: 0 4px 4px 0;
}

.section-h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #334155;
  margin: 1.35rem 0 0.5rem;
}

.runin-block {
  margin-bottom: 1rem;
}

.runin-term {
  font-weight: 700;
  color: var(--primary);
  font-size: 1em;
  display: inline;
  margin-right: 0.5rem;
}

.runin-body {
  display: inline;
}

.article-list {
  margin: 0.75rem 0 1.25rem 1.75rem;
}

.article-list li {
  margin-bottom: 0.45rem;
  line-height: 1.7;
}

.article-p {
  margin-bottom: 1.25rem;
}

/* Hyperlinks */
.xref-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  font-size: 1em;
  padding: 0.05rem 0.3rem;
  background: #e0f2fe;
  border-radius: 4px;
}

.entity-link {
  color: #1d4ed8;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
  font-weight: 500;
  font-size: 1em;
  transition: all 0.15s;
}

.entity-link:hover {
  background: #e0e7ff;
  border-radius: 3px;
}

/* Figures and Tables */
.article-figure {
  margin: 2rem 0;
  text-align: center;
  background: #ffffff;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.article-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.fig-caption {
  font-size: 0.875rem;
  color: #475569;
  margin-top: 0.75rem;
}

.article-callout-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.box-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.box-tag {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.box-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.box-body {
  font-size: 0.95rem;
  line-height: 1.7;
  overflow-x: auto;
}

.box-table {
  margin-top: 0.5rem;
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
}

.box-table th {
  background: #edf2f7;
  color: #1e3a8a;
  font-weight: 700;
  border-bottom: 2px solid #cbd5e1;
}

.box-table td {
  padding: 0.75rem 1rem;
  vertical-align: top;
  border: 1px solid #e2e8f0;
}

.box-table tr:nth-child(even) td {
  background-color: #f8fafc;
}

.article-table-wrap {
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.table-caption {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.article-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  background: #ffffff;
}

.article-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
}

.article-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  line-height: 1.6;
  vertical-align: top;
}

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

.table-note {
  font-size: 0.85rem;
  color: #64748b;
  padding: 0.6rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  margin: 0;
}

.badge-code {
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 700;
  font-family: monospace;
}

.badge-code.sys {
  background: #e0f2fe;
  color: #0369a1;
}

.sec-code-badge {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: monospace;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.35rem;
  align-self: flex-start;
}

.sys-code-badge {
  background: #e0f2fe;
  color: #0284c7;
}

/* Section Glossary Table */
.section-glossary-table {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}

.section-glossary-table h3 {
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.glossary-table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.glossary-table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-main);
  font-weight: 600;
}

.glossary-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.glossary-table tr:last-child td {
  border-bottom: none;
}

.glossary-table .term-zh {
  color: var(--primary);
  width: 35%;
}

.glossary-table .term-en {
  color: #475569;
  font-family: var(--font-sans);
  width: 45%;
}

.cat-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: #f1f5f9;
  color: #475569;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Backlinks */
.backlinks-section {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px dashed var(--border);
}

.backlinks-section h3 {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.backlinks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.backlink-chip {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}

.backlink-chip:hover {
  background: var(--primary);
  color: #fff;
}

/* Right Sidebar Chips */
.sys-chips, .entity-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sys-chip {
  background: #f1f5f9;
  color: #334155;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  text-decoration: none;
  transition: background 0.15s;
}

.sys-chip:hover {
  background: #e2e8f0;
}

.entity-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
}

/* Sections Grid on List Page */
.list-page-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.list-header {
  margin-bottom: 2rem;
}

.list-header h1 {
  font-size: 2rem;
  color: var(--primary);
}

.list-header .subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.list-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.25rem;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.section-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
  box-shadow: 0 6px 12px rgba(0,0,0,0.05);
}

.sec-card-header .sec-title {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.sec-card-header .sec-en {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.sec-card-body {
  margin: 0.75rem 0;
  flex-grow: 1;
}

.sec-summary {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sec-card-footer {
  border-top: 1px solid #f1f5f9;
  padding-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.page-tag {
  color: #94a3b8;
}

.status-badge.translated {
  color: var(--success);
  font-weight: 600;
}

.view-link {
  color: var(--accent);
  font-weight: 600;
}

/* Footer */
.footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
  .article-sidebar {
    display: none;
  }
}
