/* =========================================================
   生境手记 · BioArchive — Botanical & Lab Field Journal Theme
   100% self-contained typography & tokens (zero foreign CDN)
   ========================================================= */

:root {
  --bg: #f6f8f5;
  --bg-elevated: #ffffff;
  --bg-subtle: #edf3ec;
  --bg-hero-start: #f0f6f0;
  --bg-hero-end: #fbfcfa;
  --text: #18231e;
  --text-secondary: #4a5d54;
  --text-muted: #6e8177;
  --border: #dce5dd;
  --border-strong: #c2d2c6;

  --primary: #1f5c43;
  --primary-hover: #174733;
  --primary-soft: #e3f2ea;
  --primary-ink: #123929;

  --accent: #b45309;
  --accent-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --shadow-sm: 0 1px 2px rgba(18, 42, 31, 0.05);
  --shadow-md: 0 6px 20px rgba(18, 42, 31, 0.07);
  --shadow-lg: 0 16px 40px rgba(18, 42, 31, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --max-w: 1140px;
}

[data-theme="dark"] {
  --bg: #0f1512;
  --bg-elevated: #161f1b;
  --bg-subtle: #1d2924;
  --bg-hero-start: #14221c;
  --bg-hero-end: #161f1b;
  --text: #e6efe9;
  --text-secondary: #b1c4b9;
  --text-muted: #7f968a;
  --border: #26352e;
  --border-strong: #364b41;

  --primary: #52b788;
  --primary-hover: #74c69d;
  --primary-soft: rgba(82, 183, 136, 0.14);
  --primary-ink: #b7e4c7;

  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-hover);
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* ==================== Header ==================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand:hover {
  color: var(--primary);
}
.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.nav-link {
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14.5px;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}
.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 600;
}

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

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color 0.16s, color 0.16s;
}
.search-trigger:hover {
  border-color: var(--primary);
  color: var(--text);
}
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.16s;
}
.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.admin-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.16s;
}
.admin-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.mobile-menu-btn {
  display: none;
}

/* ==================== Main Layout ==================== */

.main-content {
  flex: 1;
  padding: 28px 0 56px;
}

/* ==================== Hero Banner ==================== */

.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 92% 18%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 46%),
    linear-gradient(135deg, var(--bg-hero-start), var(--bg-hero-end));
  padding: 34px 36px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.hero-grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 85% 20%, black 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 85% 20%, black 10%, transparent 72%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.hero-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.6vw, 36px);
  line-height: 1.25;
  color: var(--text);
  letter-spacing: 0.01em;
}

.hero-subtitle {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 680px;
}

.hero-bio {
  margin: 0 0 18px;
  font-size: 14.5px;
  color: var(--text-muted);
  max-width: 680px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.area-pill {
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.area-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 10px;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--border));
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ==================== Cards & Grids ==================== */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-more {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--primary);
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ==================== Article Cards ==================== */

.article-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.article-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
  cursor: pointer;
  position: relative;
}
.article-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.article-card.pinned {
  border-left: 4px solid var(--primary);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-cat {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.badge-pin {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-tag {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 500;
}

.article-card-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.38;
  color: var(--text);
}
.article-card:hover .article-card-title {
  color: var(--primary);
}

.article-card-summary {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ==================== Filter Bar ==================== */

.filter-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.input {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* ==================== Buttons ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

/* ==================== Article Reader ==================== */

.reader-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 28px;
  align-items: start;
}

.reader-article {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 38px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.reader-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 26px;
}

.reader-title {
  margin: 12px 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.32;
}

.toc-sidebar {
  position: sticky;
  top: 84px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}

.toc-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-link {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  line-height: 1.4;
}
.toc-link:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}
.toc-link.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}
.toc-d2 { padding-left: 14px; }
.toc-d3 { padding-left: 24px; font-size: 12.5px; }
.toc-d4 { padding-left: 34px; font-size: 12px; }

/* ==================== Markdown Typography ==================== */

.markdown-body {
  font-size: 16px;
  line-height: 1.82;
  color: var(--text);
  word-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--font-serif);
  color: var(--text);
  margin: 1.6em 0 0.65em;
  line-height: 1.35;
  scroll-margin-top: 84px;
}
.markdown-body h1 { font-size: 1.75em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.45em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
.markdown-body h3 { font-size: 1.22em; }
.markdown-body h4 { font-size: 1.06em; }

.heading-anchor {
  opacity: 0;
  margin-right: 6px;
  color: var(--text-muted);
  font-weight: 400;
  transition: opacity 0.15s;
}
.md-heading:hover .heading-anchor {
  opacity: 1;
}

.markdown-body p {
  margin: 0 0 1.05em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1.1em;
  padding-left: 1.6em;
}
.markdown-body li {
  margin: 0.35em 0;
}

.markdown-body blockquote {
  margin: 1.2em 0;
  padding: 12px 18px;
  border-left: 4px solid var(--primary);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}
.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body code:not(.hljs) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--primary-ink);
}

.code-block {
  margin: 1.2em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

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

.code-copy-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 12px;
  cursor: pointer;
}
.code-copy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
}
.code-block pre code.hljs {
  background: transparent;
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.2em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.markdown-body th {
  background: var(--bg-subtle);
  font-weight: 600;
}
.markdown-body tr:last-child td {
  border-bottom: none;
}

.math-display {
  overflow-x: auto;
  padding: 8px 4px;
  margin: 1em 0;
  text-align: center;
}

.article-figure {
  margin: 1.4em 0;
  text-align: center;
}
.article-img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.article-figure figcaption {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.reader-nav {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.reader-nav-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.reader-nav-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.reader-nav-card.next {
  text-align: right;
}
.reader-nav-label {
  font-size: 12px;
  color: var(--text-muted);
}
.reader-nav-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ==================== Files Library ==================== */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.crumb-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  font-weight: 500;
}
.crumb-btn:hover {
  background: var(--primary-soft);
}
.crumb-current {
  color: var(--text);
  font-weight: 600;
  padding: 3px 6px;
}
.crumb-sep {
  color: var(--text-muted);
}

.file-table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 110px 140px auto;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.13s;
}
.file-row:last-child {
  border-bottom: none;
}
.file-row.file-head {
  background: var(--bg-subtle);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 18px;
}
.file-row:not(.file-head):hover {
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--bg-elevated));
}

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  cursor: pointer;
}

.file-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.icon-folder { background: #fef3c7; color: #b45309; }
.icon-pdf { background: #fee2e2; color: #b91c1c; }
.icon-bio { background: #dcfce7; color: #15803d; }
.icon-table { background: #d1fae5; color: #047857; }
.icon-image { background: #e0e7ff; color: #4338ca; }
.icon-video { background: #f3e8ff; color: #7e22ce; }
.icon-audio { background: #fae8ff; color: #a21caf; }
.icon-word { background: #dbeafe; color: #1d4ed8; }
.icon-ppt { background: #ffedd5; color: #c2410c; }
.icon-excel { background: #d1fae5; color: #065f46; }
.icon-code, .icon-markdown, .icon-text { background: #e2e8f0; color: #334155; }
.icon-archive { background: #f1f5f9; color: #475569; }
.icon-cloud { background: #e0f2fe; color: #0369a1; }
.icon-other { background: var(--bg-subtle); color: var(--text-secondary); }

.cloud-link-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.cloud-link-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid #0284c7;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.cloud-link-main {
  min-width: 0;
  flex: 1;
}

.cloud-link-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}

.cloud-link-desc {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

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

.code-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

[data-theme="dark"] .icon-cloud,
[data-theme="dark"] .badge-cloud {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
}

@media (max-width: 720px) {
  .cloud-link-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==================== Courseware & Textbook Shelf ==================== */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.textbook-shelf {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.gaosan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.course-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
  cursor: pointer;
}
.course-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.course-cover {
  position: relative;
  height: 136px;
  padding: 16px 18px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-size: cover;
  background-position: center;
}
.course-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.34));
  pointer-events: none;
}
.course-cover > * {
  position: relative;
  z-index: 1;
}
.course-cover-tag {
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
}
.course-cover-label {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.course-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.course-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text);
}

.course-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.price-now {
  font-size: 20px;
  font-weight: 800;
  color: #c2410c;
}
.price-now.free {
  color: var(--primary);
  font-size: 16px;
}
.price-orig {
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.bundle-banner {
  background: linear-gradient(135deg, #14532d 0%, #1f5c43 52%, #2b6cb0 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  box-shadow: var(--shadow-md);
}

/* Course Detail & Preview Gallery */
.course-detail-hero {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.preview-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.preview-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.16s, border-color 0.16s;
}
.preview-thumb:hover {
  transform: scale(1.02);
  border-color: var(--primary);
}

/* Purchase & Unlock Modal */
.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.modal-tab-btn {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.modal-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 14px 0;
}
.qr-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  background: var(--bg);
}
.qr-card img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
  padding: 4px;
}

.delivery-unlocked-box {
  border: 2px solid var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-top: 14px;
}

/* ==================== Literature Library ==================== */

.lit-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lit-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.lit-title {
  margin: 6px 0 6px;
  font-family: var(--font-serif);
  font-size: 18.5px;
  line-height: 1.4;
  color: var(--text);
}

.lit-journal {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.lit-abstract {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.lit-teaching-box {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  color: var(--primary-ink);
  font-size: 13.5px;
  margin-bottom: 12px;
}

@media (max-width: 1024px) {
  .textbook-shelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gaosan-grid {
    grid-template-columns: 1fr;
  }
  .course-detail-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .textbook-shelf {
    grid-template-columns: 1fr;
  }
}

.file-title-wrap {
  min-width: 0;
}
.file-title {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-subpath {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta-col {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recent-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recent-file-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.recent-file-item:first-child {
  padding-top: 0;
}

/* ==================== Modal / Preview / Search ==================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 18, 14, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog.search-dialog {
  max-width: 680px;
  align-self: flex-start;
  margin-top: 8vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.modal-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  padding: 20px;
  overflow: auto;
  flex: 1;
}

.preview-iframe {
  width: 100%;
  height: 72vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.preview-video {
  width: 100%;
  max-height: 72vh;
  border-radius: var(--radius-sm);
  background: #000;
}

.preview-pre {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  max-height: 68vh;
  white-space: pre-wrap;
  word-break: break-all;
}

.fasta-header-line {
  color: var(--primary);
  font-weight: 700;
}

.csv-preview-wrap {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--font-mono);
}
.csv-preview-table th,
.csv-preview-table td {
  padding: 7px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.csv-preview-table th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  font-weight: 600;
  z-index: 1;
}

.search-results-group {
  margin-top: 14px;
}
.search-group-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-result-item:hover {
  background: var(--primary-soft);
}

/* ==================== Empty & Loading ==================== */

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg-elevated);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 200;
  box-shadow: var(--shadow-md);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== Footer ==================== */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ==================== Responsive ==================== */

@media (max-width: 960px) {
  .hero-content {
    grid-template-columns: 1fr;
  }
  .stats-panel {
    grid-template-columns: repeat(4, 1fr);
  }
  .home-grid {
    grid-template-columns: 1fr;
  }
  .reader-layout {
    grid-template-columns: 1fr;
  }
  .toc-sidebar {
    display: none;
  }
  .reader-article {
    padding: 24px 20px;
  }
}

@media (max-width: 720px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 0;
  }
  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }
  .hero-card {
    padding: 22px 18px;
  }
  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }
  .file-row.file-head {
    display: none;
  }
  .file-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .file-meta-col {
    display: inline-block;
    margin-right: 12px;
  }
  .reader-nav {
    grid-template-columns: 1fr;
  }
}
