* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  color: #263238;
  background: #f4f7f9;
}

a {
  color: #0f6cbd;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.header {
  position: fixed;
  z-index: 1000;
  inset: 0 0 auto 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  color: #fff;
  background: #155e75;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.logo:hover {
  color: #fff;
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.header-right a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
}

.menu-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.layout {
  display: flex;
  min-height: 100vh;
  padding-top: 56px;
}

.sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  width: 292px;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #d8e1e8;
}

.sidebar-header {
  padding: 16px 20px;
  color: #155e75;
  font-size: 14px;
  font-weight: 700;
  background: #eef7fa;
  border-bottom: 1px solid #d8e1e8;
}

.sidebar-nav {
  padding: 8px 0;
}

.nav-group {
  border-bottom: 1px solid #eef2f5;
}

.nav-group-title {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.nav-group-title.current {
  color: #0e7490;
  background: #ecfeff;
}

.nav-title-text {
  min-width: 0;
}

.nav-status {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.nav-status.completed {
  color: #166534;
  background: #dcfce7;
}

.nav-status.pending {
  color: #92400e;
  background: #fef3c7;
}

.arrow {
  margin-left: auto;
  color: #78909c;
  font-size: 10px;
  transition: transform 0.2s;
}

.nav-group-title.active .arrow {
  transform: rotate(90deg);
}

.nav-sub {
  display: none;
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.nav-sub.show {
  display: block;
}

.nav-sub a {
  display: block;
  padding: 6px 18px 6px 36px;
  color: #52616b;
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid transparent;
}

.nav-sub a:hover {
  color: #0e7490;
  background: #f2fbfd;
  text-decoration: none;
}

.nav-sub a.active {
  color: #0f5060;
  background: #e0f2fe;
  border-left-color: #0e7490;
  font-weight: 700;
}

.main-content {
  width: calc(100% - 292px);
  max-width: 1280px;
  min-width: 0;
  margin-left: 292px;
  padding: 30px 40px 56px;
}

.home-hero {
  padding: 36px 0 30px;
  border-bottom: 1px solid #d8e1e8;
  margin-bottom: 28px;
}

.home-hero h1 {
  margin: 0 0 10px;
  color: #12313f;
  font-size: 30px;
  line-height: 1.25;
}

.home-hero p {
  max-width: 760px;
  margin: 0;
  color: #52616b;
  line-height: 1.8;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.chapter-card {
  display: block;
  min-height: 132px;
  padding: 18px;
  color: #263238;
  background: #fff;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
}

.chapter-card:hover {
  border-color: #0e7490;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}

.chapter-card.disabled {
  cursor: default;
}

.chapter-card.disabled:hover {
  border-color: #d8e1e8;
  box-shadow: none;
}

.card-label,
.chapter-badge {
  display: inline-block;
  padding: 3px 10px;
  color: #fff;
  background: #0e7490;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.completed {
  color: #166534;
  background: #dcfce7;
}

.status-pill.pending {
  color: #92400e;
  background: #fef3c7;
}

.chapter-card h3 {
  margin: 12px 0 10px;
  font-size: 16px;
  line-height: 1.5;
}

.card-meta,
.chapter-meta {
  color: #6b7c86;
  font-size: 13px;
}

.chapter-title {
  margin: 12px 0 8px;
  color: #12313f;
  font-size: 28px;
  line-height: 1.35;
}

.pdf-pages {
  display: grid;
  gap: 18px;
}

.pdf-page {
  margin: 0;
  padding: 12px;
  background: #fff;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
}

.pdf-page img {
  display: block;
  width: 100%;
  height: auto;
}

.pdf-page figcaption {
  padding: 8px 2px 0;
  color: #6b7c86;
  font-size: 12px;
  text-align: right;
}

.section-heading {
  margin: 46px 0 22px;
  padding: 14px 18px;
  background: #ecfeff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  scroll-margin-top: 78px;
}

.section-heading h2 {
  margin: 0;
  color: #0f5060;
  font-size: 24px;
  line-height: 1.35;
}

.chapter-title-inline {
  margin: 28px 0 14px;
  color: #12313f;
  font-size: 24px;
  line-height: 1.35;
}

.subsection-heading {
  margin: 30px 0 14px;
  padding: 0 0 8px;
  color: #0e7490;
  font-size: 19px;
  line-height: 1.4;
  border-bottom: 1px solid #d8e1e8;
}

.subsection-heading.numbered-heading {
  padding-left: 0;
  text-indent: 0;
}

.content-text {
  margin: 0 0 18px;
  color: #263238;
  font-size: 17px;
  line-height: 2.12;
  letter-spacing: 0.025em;
  text-indent: 2em;
}

.content-text.list-like {
  position: relative;
  margin-left: 2.2em;
  padding-left: 30px;
  text-indent: 0;
  line-height: 2.08;
}

.content-text.list-like::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.92em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0e7490;
}

h4.subsection-heading {
  margin: 26px 0 14px;
  padding: 0;
  color: #075985;
  background: transparent;
  border: 0;
  font-size: 18px;
  font-weight: 700;
}

h4.subsection-heading::before {
  content: none;
}

.minor-section {
  margin: 28px 0 34px 2em;
  padding-left: 22px;
  background: transparent;
  border-left: 0;
}

.numbered-section {
  margin: 24px 0 34px;
  padding-left: 0;
  border-left: 0;
}

.numbered-section > .numbered-heading {
  margin: 34px 0 18px;
  padding: 0 0 10px;
  color: #0f5060;
  border: 0;
  border-bottom: 1px solid #d8e1e8;
  font-size: 20px;
  line-height: 1.45;
}

.numbered-section > .content-text,
.numbered-section > .note-box,
.numbered-section > .code-block,
.numbered-section > .content-table,
.numbered-section > .inline-figure,
.numbered-section > .table-caption {
  max-width: none;
}

.minor-section > .subsection-heading {
  margin: 0 0 14px -22px;
  padding: 0 0 8px;
  color: #075985;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e2edf3;
  font-size: 18px;
  line-height: 1.5;
}

.minor-section > .content-text {
  margin-bottom: 14px;
}

.minor-section .content-text.list-like {
  margin-left: 0.8em;
}

.minor-section > .content-text:last-child,
.minor-section > .content-table:last-child,
.minor-section > .inline-figure:last-child {
  margin-bottom: 10px;
}

.term-label {
  color: #0f5060;
  font-weight: 700;
}

.note-box {
  display: flex;
  gap: 14px;
  margin: 22px 0 26px;
  padding: 18px 22px;
  color: #334155;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 5px solid #0e7490;
  border-radius: 8px;
  font-size: 16px;
  line-height: 2;
  letter-spacing: 0.02em;
}

.note-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: #0e7490;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}

.note-text {
  flex: 1 1 auto;
  min-width: 0;
}

.ocr-content {
  max-width: 1040px;
  margin: 0 auto;
  padding: 46px 64px;
  background: #fff;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.ocr-content.preserve-lines {
  max-width: 900px;
  margin: 0 auto;
  padding: 34px 44px;
  border-color: #e6e6e6;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.ocr-content.preserve-lines .content-text {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.95;
  margin-bottom: 16px;
}

.ocr-content.preserve-lines .content-text.list-like {
  padding-left: 24px;
}

.ocr-content.preserve-lines .chapter-title-inline {
  margin: 4px 0 24px;
  padding-bottom: 14px;
  color: #333;
  font-size: 30px;
  border-bottom: 1px solid #e6e6e6;
}

.ocr-content.preserve-lines .section-heading {
  margin: 42px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e6e6e6;
}

.ocr-content.preserve-lines .subsection-heading {
  margin: 30px 0 16px;
  padding: 0 0 0 12px;
  font-size: 20px;
  color: #333;
  border-left: 4px solid #16a34a;
}

.ocr-content .code-block {
  margin: 18px 0 24px;
  padding: 16px 18px;
  white-space: pre-wrap;
  text-indent: 0;
  letter-spacing: 0;
}

.ocr-content.preserve-lines .code-block {
  color: #333;
  background: #f6f6f6;
  border: 1px solid #e3e3e3;
  border-left: 4px solid #16a34a;
  font-size: 14px;
  line-height: 1.75;
}

.ocr-content.preserve-lines .content-table {
  margin: 14px 0 24px;
  background: #fff;
  box-shadow: none;
}

.ocr-content.preserve-lines .content-table thead th {
  background: #f5f5f5;
  color: #333;
  border-bottom-color: #d6d6d6;
}

.content-table {
  width: 100%;
  margin: 16px 0 26px;
  border-collapse: collapse;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-size: 15px;
  line-height: 1.75;
}

.content-table th,
.content-table td {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  vertical-align: top;
}

.content-table thead th {
  color: #12313f;
  background: #eaf4f8;
  font-weight: 700;
}

.content-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.ocr-content.preserve-lines .table-caption {
  margin-top: 18px;
  color: #333;
  font-size: 15px;
}

.figure-caption,
.table-caption {
  margin: 10px 0 18px;
  color: #546e7a;
  font-size: 13px;
  text-align: center;
}

.inline-figure {
  display: block;
  clear: both;
  margin: 24px auto 30px;
  padding: 12px;
  width: min(100%, 720px);
  background: #f8fafc;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
  text-align: center;
}

.ocr-content.preserve-lines .inline-figure {
  max-width: 700px;
}

.inline-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 620px;
  object-fit: contain;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.inline-figure figcaption {
  margin-top: 8px;
  color: #546e7a;
  font-size: 13px;
}

.table-caption {
  color: #0f5060;
  font-weight: 700;
}

.source-pages {
  margin-top: 28px;
}

.source-pages summary {
  cursor: pointer;
  color: #0f5060;
  font-weight: 700;
}

.text-extract {
  margin-top: 28px;
  padding: 16px;
  background: #fff;
  border: 1px solid #d8e1e8;
  border-radius: 8px;
}

.text-extract summary {
  cursor: pointer;
  color: #0f5060;
  font-weight: 700;
}

.text-extract pre {
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  font: 13px/1.7 "Cascadia Mono", Consolas, "Microsoft YaHei UI", monospace;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}

.chapter-nav a {
  max-width: 48%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #d8e1e8;
  border-radius: 6px;
}

.footer {
  margin-left: 292px;
  padding: 22px 40px;
  color: #6b7c86;
  font-size: 13px;
}

.overlay {
  display: none;
}

@media (max-width: 820px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  .overlay.show {
    display: block;
    position: fixed;
    z-index: 90;
    inset: 56px 0 0;
    background: rgba(15, 23, 42, 0.35);
  }

  .main-content,
  .footer {
    margin-left: 0;
  }

  .main-content {
    padding: 22px 16px 44px;
  }

  .chapter-title {
    font-size: 24px;
  }
}
