/* Modern Academic Style CSS (现代学术风) */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Georgia", "Cambria", "Times New Roman", "Songti SC", "Noto Serif SC", serif;
  --font-mono: "JetBrains Mono", "Fira Code", Menlo, Monaco, Consolas, "Courier New", monospace;

  /* Color Palette: Oxford Slate & Academic Blue */
  --academic-primary: #1e3a8a;
  --academic-accent: #2563eb;
  --academic-accent-hover: #1d4ed8;
  --academic-accent-light: #eff6ff;
  --academic-accent-border: #bfdbfe;

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-alt: #fcfbf9;

  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-active: #cbd5e1;

  --badge-pdf-bg: #fef2f2;
  --badge-pdf-text: #b91c1c;
  --badge-pdf-border: #fecaca;

  --badge-docx-bg: #eff6ff;
  --badge-docx-text: #1d4ed8;
  --badge-docx-border: #bfdbfe;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-body);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--academic-accent);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

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

/* Header & Top Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
}

.header-container {
  max-width: 1560px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-section {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--academic-primary), var(--academic-accent));
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.brand-logo:hover {
  color: var(--academic-accent);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-body);
}

.nav-link:hover {
  color: var(--academic-accent);
  background-color: var(--bg-subtle);
}

.nav-link.active {
  color: var(--academic-primary);
  background-color: var(--academic-accent-light);
  font-weight: 600;
}

.header-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Bilingual Pill Switcher */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 3px;
  font-size: 0.85rem;
  font-weight: 500;
}

.skip-to-content {
  position: absolute;
  top: -60px;
  left: 16px;
  background: var(--academic-accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-to-content:focus {
  top: 12px;
}

.lang-btn {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.lang-btn:hover {
  color: var(--text-main);
}

.lang-btn.active {
  background-color: var(--bg-card);
  color: var(--academic-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.lang-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: none;
}

.mobile-menu-btn {
  display: none;
  padding: 8px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-body);
  cursor: pointer;
}

/* Main Layout Container */
.main-wrapper {
  flex: 1;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* Reader 3-Column Layout */
.reader-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 220px;
  gap: 36px;
  align-items: start;
}

.course-sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 8px;
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 8px;
}

.course-tree {
  list-style: none;
}

.section-group {
  margin-bottom: 18px;
}

.section-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-docs {
  list-style: none;
  margin-left: 8px;
  border-left: 1px solid var(--border-color);
  padding-left: 8px;
  margin-top: 4px;
}

.doc-nav-item {
  margin-bottom: 2px;
}

.doc-nav-link {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-body);
  line-height: 1.4;
}

.doc-nav-link:hover {
  background-color: var(--bg-subtle);
  color: var(--academic-accent);
}

.doc-nav-link.active {
  background-color: var(--academic-accent-light);
  color: var(--academic-primary);
  font-weight: 600;
  border-left: 2px solid var(--academic-accent);
}

.sidebar-footer-link {
  margin-top: 16px;
  padding: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
}

/* Center Content Column */
.content-canvas {
  min-width: 0;
  overflow-wrap: anywhere;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 40px 52px;
}

/* Breadcrumbs */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.breadcrumb-separator {
  color: var(--text-light);
}

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

.breadcrumb-nav a:hover {
  color: var(--academic-accent);
}

/* Document Header & Meta */
.doc-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
  margin-bottom: 28px;
}

.doc-title {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.doc-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.doc-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Translation Status Banner */
.translation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background-color: #fefce8;
  border: 1px solid #fef08a;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.88rem;
  color: #854d0e;
}

.translation-banner.conflict {
  background-color: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

.banner-link {
  font-weight: 600;
  text-decoration: underline;
  color: inherit;
}

/* Markdown Academic Typography */
.prose {
  font-size: 1.05rem;
  color: var(--text-body);
  line-height: 1.8;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.35;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  scroll-margin-top: 80px;
}

.prose h2 {
  font-size: 1.45rem;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.prose h3 {
  font-size: 1.2rem;
}

.prose p {
  margin-bottom: 1.25em;
}

.prose ul, .prose ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 12px 20px;
  background-color: var(--bg-subtle);
  border-left: 4px solid var(--academic-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-body);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5em 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.table-container table,
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.95rem;
}

.prose th, .prose td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.prose th {
  background-color: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-main);
}

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

.prose tr:nth-child(even) td {
  background-color: #fafbfc;
}

.prose img {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin: 1.8em auto;
  box-shadow: var(--shadow-sm);
}

/* Pygments Code Blocks with Copy Header */
.code-block {
  margin: 1.5em 0;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background-color: #f1f5f9;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-lang {
  font-family: var(--font-mono);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--academic-accent);
  border-color: var(--academic-accent-border);
}

.copy-btn.copied {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}

.prose :not(pre) > code {
  background-color: #f1f5f9;
  color: #c026d3;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88em;
  border: 1px solid #e2e8f0;
}

/* Pagination: Prev / Next */
.doc-pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.pag-card {
  min-width: 0;
  padding: 14px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}

.pag-card:hover {
  border-color: var(--academic-accent);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.pag-card.next {
  text-align: right;
  grid-column: 2;
}

.pag-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.pag-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--academic-accent);
}

/* Right TOC Column */
.toc-sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  font-size: 0.85rem;
  padding-left: 8px;
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  border-left: 1px solid var(--border-color);
}

.toc-item {
  margin-bottom: 6px;
}

.toc-item.level-3 {
  padding-left: 12px;
}

.toc-link {
  display: block;
  padding: 3px 0 3px 12px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--academic-accent);
}

.toc-link.active {
  color: var(--academic-primary);
  font-weight: 600;
  border-left-color: var(--academic-accent);
}

/* Homepage Styles */
.hero-banner {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-page) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
}

.hero-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 24px;
}

.hero-search-form {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}

.search-input {
  min-width: 0;
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  background-color: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--academic-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background-color: var(--academic-accent);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

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

/* Course Grid */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 24px;
}

.course-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  word-break: break-word;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-active);
}

.course-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.course-card-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.course-badge {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}

.course-card-desc {
  font-size: 0.92rem;
  color: var(--text-body);
  margin-bottom: 20px;
  flex: 1;
}

.course-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.course-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Downloads Page Styles */
.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.filter-toolbar {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.filter-group {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-select {
  min-width: 0;
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  background-color: #fff;
  color: var(--text-body);
}

.filter-pills {
  display: flex;
  gap: 4px;
}

.filter-pill {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
}

.filter-pill.active {
  background-color: var(--academic-accent);
  color: #fff;
  border-color: var(--academic-accent);
}

.downloads-table-container {
  min-width: 0;
  max-width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.downloads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.downloads-table th, .downloads-table td {
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.downloads-table th {
  background-color: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.downloads-table tr:hover td {
  background-color: #fafbfc;
}

.file-format-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.file-format-badge.pdf {
  background-color: var(--badge-pdf-bg);
  color: var(--badge-pdf-text);
  border: 1px solid var(--badge-pdf-border);
}

.file-format-badge.docx {
  background-color: var(--badge-docx-bg);
  color: var(--badge-docx-text);
  border: 1px solid var(--badge-docx-border);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--academic-accent);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--academic-accent);
  background-color: #fff;
  transition: all 0.15s ease;
}

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

/* Empty States */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-light);
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  padding: 24px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Mobile Collapsible Table of Contents */
.mobile-toc {
  display: none;
  margin-bottom: 24px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.mobile-toc-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  font-size: 0.95rem;
}

.mobile-toc-summary:focus {
  outline: 2px solid var(--academic-accent);
  outline-offset: 2px;
}

.mobile-toc-list {
  margin: 12px 0 0 0;
  padding-left: 20px;
  list-style: disc;
}

.mobile-toc-list .toc-item {
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.mobile-toc-list .toc-link {
  color: var(--text-body);
  text-decoration: none;
}

.mobile-toc-list .toc-link:hover {
  color: var(--academic-accent);
}

/* Responsive Styles */
.mobile-site-menu { display: none; }
.search-query-field { display: flex; flex: 1; min-width: 0; }
.search-actions, .search-result-meta, .search-download-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.search-download-result { justify-content: space-between; }
.search-download-result > div { min-width: 0; }
.filter-search { flex: 1; flex-wrap: nowrap; }
.math.block, .math.display { display: block; max-width: 100%; overflow-x: auto; }
.math .katex-display { margin: 0.75em 0; }
.course-card-meta, .course-card-actions, .translation-banner { flex-wrap: wrap; }
.doc-title, .page-title, .hero-title, .breadcrumb-nav, .pag-title,
.course-sidebar, .toc-sidebar, .footer-container { overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .header-nav { display: none; }
  .header-container, .header-actions { gap: 8px; }
  .brand-section { flex: 1; }
  .brand-logo span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-site-menu { display: block; }
  .mobile-site-menu summary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
  }
  .mobile-site-menu summary::-webkit-details-marker { display: none; }
  .mobile-site-menu nav {
    position: absolute;
    top: 64px;
    right: 12px;
    left: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
  }
  .mobile-site-menu nav a { display: block; padding: 10px 12px; min-height: 44px; }
}

@media (max-width: 1199px) {
  .reader-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .toc-sidebar {
    display: none;
  }
  .mobile-toc {
    display: block;
  }
}

@media (max-width: 767px) {
  .header-container {
    padding: 0 12px;
  }
  .brand-logo span {
    font-size: 1rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .main-wrapper {
    padding: 16px 12px;
  }
  .reader-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .course-sidebar {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 280px;
    background-color: #fff;
    z-index: 100;
    padding: 20px;
    box-shadow: var(--shadow-lg);
  }
  .course-sidebar.open {
    display: block;
  }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    gap: 8px;
    margin-bottom: 12px;
  }
  .content-canvas {
    padding: 20px 12px;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .prose {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .prose pre, .code-block {
    max-width: 100%;
    overflow-x: auto;
  }
  .header-nav {
    display: none;
  }
  .course-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .course-card {
    min-width: 0;
    padding: 18px 14px;
  }
  .hero-banner {
    padding: 32px 14px;
  }
  .hero-search-form {
    flex-direction: column;
    width: 100%;
  }
  .hero-search-form .search-input {
    width: 100%;
    min-width: 0;
  }
  .search-page-form {
    flex-direction: column;
    align-items: stretch;
  }
  .search-page-form .search-input {
    width: 100%;
    min-width: 0;
  }
  .filter-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-actions { align-items: stretch; }
  .search-actions .filter-select { flex: 1 1 120px; }
  .search-actions .btn-primary { flex: 1 1 160px; }
  .filter-search { width: 100%; }
  .filter-label { flex-basis: 100%; }
  .lang-switcher { padding: 2px; }
  .lang-btn { padding: 4px 8px; }
  .doc-nav-link, .toc-link { min-height: 44px; }
  .btn-download, .filter-pill, .filter-select, .search-input, .mobile-toc-summary { min-height: 44px; }
  .btn-primary {
    min-height: 44px;
    justify-content: center;
  }
  .lang-btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .copy-btn {
    min-height: 44px;
    padding: 6px 12px;
  }
}
