/* AllScience — Publication Reading Page */

/* Reading progress bar */
.reading-progress {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px; z-index: var(--z-toast);
  background: rgba(59,130,246,0.1);
}
.reading-progress-fill {
  height: 100%; width: 0; background: var(--color-primary, #3b82f6);
  transition: width 0.1s linear;
}

/* Layout with ToC sidebar */
.pub-layout {
  display: flex; max-width: 1100px; margin: 0 auto; position: relative;
}

/* Table of Contents */
.pub-toc {
  width: 220px; flex-shrink: 0; padding-top: 7rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.toc-inner { padding: 0 1rem 2rem 1.5rem; }
.toc-title {
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--color-text-dim, #5a6a80);
  margin-bottom: 0.75rem;
}
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-item { margin-bottom: 0.125rem; }
.toc-link {
  display: block; padding: 0.25rem 0.5rem; font-size: 0.75rem;
  color: var(--color-text-muted, #8896ab); text-decoration: none;
  border-left: 2px solid transparent; border-radius: 0 4px 4px 0;
  transition: all 0.15s; line-height: 1.4;
}
.toc-link:hover { color: var(--color-text, #e2e8f0); background: rgba(59,130,246,0.05); }
.toc-link.active {
  color: var(--color-primary, #3b82f6); border-left-color: var(--color-primary, #3b82f6);
  background: rgba(59,130,246,0.08); font-weight: 500;
}

/* Citation modal */
.cite-modal-body .cite-output {
  font-family: var(--font-mono, monospace); font-size: 0.8125rem;
  background: var(--color-bg, #0a0e17); line-height: 1.6;
}

.pub-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
  flex: 1; min-width: 0;
}

.pub-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border, #1e293b);
}

.pub-title {
  font-family: 'Lora', serif;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 1rem;
}

.pub-abstract {
  font-size: 1rem;
  color: var(--color-text-muted, #8896ab);
  line-height: 1.7;
  font-style: italic;
  margin-bottom: 1.5rem;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-dim, #5a6a80);
}

.pub-meta-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.pub-keywords {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 1rem;
}

.pub-keyword {
  padding: 0.125rem 0.625rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 100px;
  font-size: 0.6875rem;
  color: #93bbfc;
}

/* Content sections */
.pub-section {
  margin-bottom: 2rem;
}

.pub-section-title {
  font-family: 'Lora', serif;
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.pub-section-content {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--color-text-muted, #8896ab);
}

.pub-section-content p {
  margin-bottom: 1rem;
  text-indent: 1.5em;
}

.pub-section-content p:first-child { text-indent: 0; }

/* Action bar */
.pub-actions {
  display: flex; justify-content: center; gap: 0.75rem;
  margin-top: 2rem; padding-top: 1.5rem;
  border-top: 1px solid var(--color-border, #1e293b);
}

/* Footer */
.pub-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border, #1e293b);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-dim, #5a6a80);
}

.pub-doi {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--color-primary, #3b82f6);
  margin-top: 0.5rem;
}

.pub-views { margin-top: 0.5rem; }
.pub-open-access { font-size: 0.75rem; color: var(--color-success, #10b981); margin-top: 0.5rem; }

.pub-cta {
  margin-top: 2rem;
  padding: 2rem;
  background: var(--color-bg-secondary, #111827);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 10px;
  text-align: center;
}

.pub-cta p {
  color: var(--color-text-muted, #8896ab);
  margin-bottom: 1rem;
}

/* Bookmarked state */
.bookmarked { background: rgba(59,130,246,0.15) !important; color: var(--color-primary, #3b82f6) !important; border-color: var(--color-primary, #3b82f6) !important; }

/* Comments */
.pub-comments {
  margin-top: 3rem; padding-top: 2rem;
  border-top: 1px solid var(--color-border, #1e293b);
}
.pub-comments h3 { margin-bottom: 1.5rem; }

.comment-form { margin-bottom: 1.5rem; }
.comment-form textarea { margin-bottom: 0.75rem; width: 100%; }

.comment-item {
  padding: 1rem 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.comment-author { font-weight: 600; font-size: 0.875rem; color: var(--color-text, #e2e8f0); }
.comment-date { font-size: 0.6875rem; color: var(--color-text-dim, #5a6a80); margin-bottom: 0.375rem; }
.comment-text { font-size: 0.875rem; color: var(--color-text-muted, #8896ab); line-height: 1.6; }

/* Related works / from this author */
.pub-related { margin-top: 2.5rem; }
.pub-related h3 { margin-bottom: 1rem; font-size: 1.125rem; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.related-card {
  display: block; padding: 1.25rem;
  background: var(--color-bg-secondary, #111827);
  border: 1px solid var(--color-border, #1e293b); border-radius: 8px;
  text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.related-card:hover { border-color: var(--color-primary, #3b82f6); transform: translateY(-1px); }
.related-card-title { font-weight: 600; font-size: 0.875rem; line-height: 1.4; margin-bottom: 0.375rem; color: var(--color-text, #e2e8f0); }
.related-card-desc { font-size: 0.75rem; color: var(--color-text-muted, #8896ab); line-height: 1.5; }
.related-card-keywords { display: flex; gap: 0.25rem; margin-top: 0.375rem; }
.related-card-keywords span { font-size: 0.6rem; padding: 0.0625rem 0.375rem; background: rgba(59,130,246,0.08); border-radius: 100px; color: #93bbfc; }
.related-see-all { display: block; margin-top: 0.75rem; font-size: 0.8125rem; color: var(--color-primary, #3b82f6); text-decoration: none; }
.related-see-all:hover { text-decoration: underline; }

@media (max-width: 768px) { .related-grid { grid-template-columns: 1fr; } }

/* Not found state */
.pub-not-found {
  text-align: center;
  padding: 6rem 2rem;
}

.pub-not-found h2 { margin-bottom: 1rem; }
.pub-not-found p { color: var(--color-text-muted, #8896ab); }

@media (max-width: 960px) {
  .pub-toc { display: none; }
  .pub-layout { display: block; }
}

@media (max-width: 768px) {
  .pub-title { font-size: 1.75rem; }
  .pub-container { padding: 5rem 1rem 3rem; }
}

/* Reading time badge */
.pub-reading-time {
  background: rgba(16, 185, 129, 0.12);
  color: var(--color-success, #10b981);
  padding: 0.125rem 0.5rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Social share group */
.pub-share-group {
  display: flex; gap: 0.375rem; margin-left: 0.5rem;
}
.share-social-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--color-bg-secondary, #111827);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 50%; cursor: pointer;
  font-size: 0.8125rem; font-weight: 700;
  color: var(--color-text-muted, #8896ab);
  text-decoration: none;
  transition: all 0.15s;
}
.share-social-btn:hover {
  border-color: var(--color-primary, #3b82f6);
  color: var(--color-primary, #3b82f6);
  background: rgba(59,130,246,0.08);
}

/* ── Reading Mode Toggle Button ─────────────────────────────────── */
.rm-toggle-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.875rem; border-radius: 6px;
  background: var(--color-bg-secondary, #111827);
  border: 1px solid var(--color-border, #1e293b);
  color: var(--color-text-muted, #8896ab);
  font-size: 0.8125rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s;
}
.rm-toggle-btn:hover {
  border-color: var(--color-primary, #3b82f6);
  color: var(--color-primary, #3b82f6);
  background: rgba(59,130,246,0.08);
}
.rm-toggle-btn .rm-icon { font-size: 1rem; }

/* ── Reading Mode Active State ─────────────────────────────────── */
body.reading-mode {
  --rm-bg: #faf9f6;
  --rm-text: #2c2c2c;
  --rm-text-muted: #555;
  --rm-border: #e0ddd8;
  --rm-accent: #3b82f6;
}
[data-theme="dark"] body.reading-mode,
body.reading-mode[data-theme="dark"] {
  --rm-bg: #1a1a2e;
  --rm-text: #d4d4d8;
  --rm-text-muted: #9ca3af;
  --rm-border: #2e2e4a;
  --rm-accent: #60a5fa;
}

body.reading-mode .navbar,
body.reading-mode .pub-toc,
body.reading-mode .pub-comments,
body.reading-mode .pub-cta,
body.reading-mode .pub-related,
body.reading-mode .pub-footer,
body.reading-mode .pub-actions,
body.reading-mode .pub-share-group {
  display: none !important;
}

body.reading-mode {
  background: var(--rm-bg) !important;
  color: var(--rm-text) !important;
}

body.reading-mode .pub-layout {
  display: block; max-width: none;
}

body.reading-mode .pub-container {
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
  max-width: var(--rm-content-width, 720px);
  font-size: var(--rm-font-size, 18px);
  line-height: var(--rm-line-spacing, 1.8);
  font-family: var(--rm-font-family, 'Inter', sans-serif);
  color: var(--rm-text);
}

body.reading-mode .pub-title {
  font-size: 2rem; color: var(--rm-text);
}

body.reading-mode .pub-abstract {
  color: var(--rm-text-muted);
}

body.reading-mode .pub-meta {
  color: var(--rm-text-muted);
}

body.reading-mode .pub-section-title {
  color: var(--rm-text);
  border-bottom-color: var(--rm-border);
}

body.reading-mode .pub-section-content {
  color: var(--rm-text-muted);
  font-size: inherit;
  line-height: inherit;
}

body.reading-mode .pub-section-content p {
  margin-bottom: 1.25em;
}

body.reading-mode .pub-header {
  border-bottom-color: var(--rm-border);
}

body.reading-mode .pub-keyword {
  background: rgba(59,130,246,0.08);
  border-color: rgba(59,130,246,0.15);
  color: var(--rm-accent);
}

/* ── Reading Mode Toolbar (floating top-right) ─────────────────── */
.rm-toolbar {
  position: fixed; top: 1rem; right: 1rem; z-index: var(--z-sidebar);
  background: var(--rm-bg, #faf9f6);
  border: 1px solid var(--rm-border, #e0ddd8);
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  min-width: 180px;
  display: flex; flex-direction: column; gap: 0.5rem;
}

.rm-toolbar-row {
  display: flex; align-items: center; gap: 0.375rem;
}

.rm-btn {
  padding: 0.25rem 0.625rem; border-radius: 5px;
  background: transparent;
  border: 1px solid var(--rm-border, #e0ddd8);
  color: var(--rm-text, #2c2c2c);
  font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.rm-btn:hover {
  border-color: var(--rm-accent, #3b82f6);
  color: var(--rm-accent, #3b82f6);
}

.rm-font-label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--rm-text-muted, #555);
  min-width: 2.5rem; text-align: center;
}

.rm-label {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--rm-text-muted, #555);
  text-transform: uppercase; letter-spacing: 0.04em;
  min-width: 3rem;
}

.rm-select {
  flex: 1; padding: 0.1875rem 0.375rem; border-radius: 4px;
  background: transparent;
  border: 1px solid var(--rm-border, #e0ddd8);
  color: var(--rm-text, #2c2c2c);
  font-size: 0.75rem; cursor: pointer;
}

.rm-exit-btn {
  width: 100%; text-align: center;
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
  color: #ef4444;
  font-size: 0.75rem;
}
.rm-exit-btn:hover {
  background: rgba(239,68,68,0.15);
  border-color: #ef4444;
  color: #ef4444;
}

.rm-toolbar-close-row {
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rm-border, #e0ddd8);
}

/* ── Reading Mode Mini-TOC (floating left) ─────────────────────── */
.rm-minitoc {
  position: fixed; top: 50%; left: 1rem; z-index: var(--z-sidebar);
  transform: translateY(-50%);
  background: var(--rm-bg, #faf9f6);
  border: 1px solid var(--rm-border, #e0ddd8);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  max-height: 60vh; overflow-y: auto;
  max-width: 200px;
}

.rm-minitoc-title {
  font-size: 0.625rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--rm-text-muted, #555);
  margin-bottom: 0.5rem;
}

.rm-minitoc-list {
  list-style: none; padding: 0; margin: 0;
}

.rm-minitoc-list li {
  margin-bottom: 0.125rem;
}

.rm-minitoc-list a {
  display: block; padding: 0.1875rem 0.5rem;
  font-size: 0.6875rem; line-height: 1.3;
  color: var(--rm-text-muted, #555);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rm-minitoc-list a:hover {
  color: var(--rm-text, #2c2c2c);
  background: rgba(59,130,246,0.05);
}

.rm-minitoc-list a.active {
  color: var(--rm-accent, #3b82f6);
  border-left-color: var(--rm-accent, #3b82f6);
  font-weight: 600;
}

/* ── Resume Banner ─────────────────────────────────────────────── */
.rm-resume-banner {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: var(--z-sidebar);
  background: var(--rm-bg, #faf9f6);
  border: 1px solid var(--rm-accent, #3b82f6);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 4px 24px rgba(59,130,246,0.15);
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.875rem; color: var(--rm-text, #2c2c2c);
}

/* ── Reading Mode Estimated Read Time (top of article) ─────────── */
.rm-read-time-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.12);
  font-size: 0.8125rem;
  color: var(--rm-text-muted, #555);
}
.rm-read-time-bar .rm-clock { font-size: 1rem; }

/* ── Publication Enhancements ──────────────────────────────────── */
.pub-share-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.pub-share-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted, #8896ab);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pub-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-bg-hover, #1e293b);
  border: 1px solid var(--color-border, #2a3a52);
  color: var(--color-text, #e2e8f0);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.pub-share-btn:hover { border-color: var(--color-primary, #3b82f6); background: rgba(59,130,246,0.1); color: var(--color-primary, #3b82f6); }
.pub-share-twitter:hover { color: #1da1f2; border-color: #1da1f2; }
.pub-share-linkedin:hover { color: #0077b5; border-color: #0077b5; }
.pub-share-facebook:hover { color: #1877f2; border-color: #1877f2; }

.pub-cite-copy-btn, .pub-bibtex-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: 1px solid var(--color-border, #2a3a52);
  color: var(--color-text, #e2e8f0);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.5rem;
  margin-right: 0.375rem;
  transition: all 0.15s;
}
.pub-cite-copy-btn:hover, .pub-bibtex-btn:hover {
  border-color: var(--color-primary, #3b82f6);
  color: var(--color-primary, #3b82f6);
  background: rgba(59,130,246,0.08);
}

.related-pubs-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border, #2a3a52);
}
.related-pubs-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.related-pubs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.related-pub-card {
  background: var(--color-bg-card, #1a2233);
  border: 1px solid var(--color-border, #2a3a52);
  border-radius: 10px;
  padding: 1rem;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.related-pub-card:hover { border-color: var(--color-primary, #3b82f6); box-shadow: 0 0 0 1px rgba(59,130,246,0.15); }
.related-pub-title { font-size: 0.875rem; font-weight: 600; color: var(--color-text, #e2e8f0); margin-bottom: 0.375rem; line-height: 1.4; }
.related-pub-meta { font-size: 0.75rem; color: var(--color-text-muted, #8896ab); }

[data-theme="light"] .pub-share-btn { background: #f1f5f9; }
[data-theme="light"] .related-pub-card { background: #fff; }

@media (max-width: 768px) {
  .related-pubs-grid { grid-template-columns: 1fr; }
}

/* ── Print-friendly styles ─────────────────────────────────────── */
@media print {
  .navbar, .pub-toc, .pub-actions, .pub-comments, .pub-cta,
  .pub-related, .pub-share-group, .reading-progress, .toast-container,
  .rm-toolbar, .rm-minitoc, .rm-resume-banner, .rm-toggle-btn,
  .rm-read-time-bar {
    display: none !important;
  }
  body, body.reading-mode {
    background: #fff !important;
    color: #000 !important;
  }
  .pub-container, body.reading-mode .pub-container {
    padding: 0 !important;
    max-width: 100% !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    color: #000 !important;
  }
  .pub-title, body.reading-mode .pub-title { color: #000 !important; font-size: 18pt !important; }
  .pub-section-title, body.reading-mode .pub-section-title { color: #000 !important; page-break-after: avoid; }
  .pub-section-content, .pub-abstract,
  body.reading-mode .pub-section-content,
  body.reading-mode .pub-abstract { color: #333 !important; }
  .pub-section { page-break-inside: avoid; }
  .pub-keyword { color: #666 !important; border-color: #ccc !important; background: #f5f5f5 !important; }
  .pub-footer { border-top-color: #ccc !important; color: #666 !important; }
  .pub-header { page-break-after: avoid; }
}

@media (max-width: 768px) {
  .pub-actions { flex-wrap: wrap; }
  .pub-share-group { width: 100%; justify-content: center; margin-left: 0; margin-top: 0.5rem; }

  /* Reading mode responsive: collapse controls */
  .rm-toolbar {
    top: auto; bottom: 0; left: 0; right: 0;
    border-radius: 12px 12px 0 0;
    flex-direction: row; flex-wrap: wrap;
    justify-content: center;
    min-width: 0; max-width: 100%;
    padding: 0.5rem 0.75rem;
    gap: 0.375rem;
  }
  .rm-toolbar-row { gap: 0.25rem; }
  .rm-toolbar-close-row { border-top: none; margin-top: 0; padding-top: 0; }

  .rm-minitoc { display: none !important; }

  body.reading-mode .pub-container {
    padding: 3rem 1rem 5rem;
    max-width: 100% !important;
  }

  .rm-resume-banner {
    bottom: auto; top: 3.5rem;
    left: 0.5rem; right: 0.5rem;
    transform: none;
    font-size: 0.8125rem;
  }
}

/* ── Reading Time & Progress ────────────────────────────────────────── */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: var(--z-popover);
  background: transparent;
  pointer-events: none;
}

.reading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary, #3b82f6), var(--color-accent, #06d6a0));
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

.reading-progress-bar:hover {
  height: 6px;
  pointer-events: auto;
}

.reading-progress-bar:hover::after {
  content: attr(data-percent);
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--color-text-muted, #8896ab);
  background: var(--color-bg-card, #1a2233);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

.reading-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--color-text-muted, #8896ab);
  margin: 0.5rem 0;
}

.reading-time-badge .reading-icon {
  font-size: 0.875rem;
}

.reading-time-remaining {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.375rem 0.875rem;
  background: var(--color-bg-card, #1a2233);
  border: 1px solid var(--color-border, #2a3a52);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-muted, #8896ab);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 100;
  pointer-events: none;
}

.reading-time-remaining.visible {
  opacity: 1;
}

/* TOC section progress */
.toc-item.toc-read .toc-check {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  background: var(--color-accent, #06d6a0);
  color: #000;
  border-radius: 50%;
  font-size: 0.5rem;
  font-weight: 700;
  margin-right: 0.375rem;
  flex-shrink: 0;
}

.toc-item .toc-check {
  display: none;
}

.toc-item.toc-active {
  color: var(--color-primary, #3b82f6);
  font-weight: 600;
}

.toc-item.toc-read {
  color: var(--color-text-dim, #5a6a80);
}

/* Section completion badge */
.section-read-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.5625rem;
  color: var(--color-accent, #06d6a0);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.section-read-badge.visible {
  opacity: 1;
}

[data-theme="light"] .reading-time-remaining {
  background: #fff;
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .reading-time-badge {
  background: rgba(59, 130, 246, 0.05);
}

@media (max-width: 768px) {
  .reading-time-remaining {
    bottom: 1rem;
    font-size: 0.625rem;
  }
}

/* ── Print Styles (Publication Page) ────────────────────────────────── */
@media print {
  .pub-topbar,
  .reading-mode-toolbar,
  .reading-progress,
  .reading-progress-bar,
  .reading-time-remaining,
  .reading-time-badge,
  .pub-toc,
  .pub-actions,
  .pub-share-bar,
  .pub-comments,
  .pub-related {
    display: none !important;
  }

  .pub-layout {
    display: block !important;
    max-width: none !important;
  }

  .pub-container,
  .pub-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }

  .pub-title {
    font-size: 18pt !important;
    margin-bottom: 6pt !important;
  }

  .pub-authors {
    font-size: 11pt !important;
    margin-bottom: 4pt !important;
  }

  .pub-abstract {
    border: 1px solid #ccc !important;
    padding: 8pt !important;
    margin-bottom: 12pt !important;
    font-style: italic;
  }

  .pub-section-title {
    font-size: 14pt !important;
    page-break-after: avoid !important;
  }

  .pub-section-content {
    font-size: 12pt !important;
    line-height: 1.6 !important;
  }

  .pub-section-content p {
    orphans: 3;
    widows: 3;
  }

  /* Reference list */
  .pub-references li {
    page-break-inside: avoid;
    font-size: 10pt !important;
    margin-bottom: 4pt !important;
  }

  .pub-keywords .keyword-tag {
    border: 1px solid #999 !important;
    padding: 1pt 4pt !important;
    font-size: 9pt !important;
  }
}

/* ── Publication Metrics Dashboard ─────────────────────────────── */
.pub-metrics-dashboard {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--color-bg-secondary, #111827);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 12px;
}

.pub-metrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.pub-metrics-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text, #e2e8f0);
  margin: 0;
}

.pub-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.pub-metrics-grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.pub-metric-card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
  background: var(--color-bg-card, #1a2233);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 10px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pub-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.pub-metric-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 2rem;
  opacity: 0.08;
  pointer-events: none;
  line-height: 1;
}

.pub-metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-text, #e2e8f0);
  line-height: 1.2;
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.pub-metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted, #8896ab);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pub-metric-trend {
  margin-top: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
}

.pub-metric-trend.trend-up {
  color: var(--color-success, #10b981);
}

.pub-metric-trend.trend-down {
  color: #ef4444;
}

.pub-donut-container {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pub-donut-value {
  font-weight: 800;
  font-family: 'Inter', sans-serif;
}

.pub-metric-card--donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pub-metric-card--chart {
  min-width: 0;
}

.pub-monthly-chart {
  width: 100%;
  overflow: hidden;
}

.pub-monthly-chart svg {
  display: block;
}

.pub-monthly-bar {
  transition: opacity 0.15s;
  cursor: default;
}

.pub-monthly-bar:hover {
  opacity: 1 !important;
  filter: brightness(1.3);
}

.pub-metric-card--shares {
  margin-bottom: 0;
}

.pub-share-breakdown {
  width: 100%;
}

.pub-share-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 0.625rem;
}

.pub-share-segment {
  height: 100%;
  min-width: 4px;
  transition: filter 0.15s;
}

.pub-share-segment:first-child {
  border-radius: 7px 0 0 7px;
}

.pub-share-segment:last-child {
  border-radius: 0 7px 7px 0;
}

.pub-share-segment:hover {
  filter: brightness(1.25);
}

.pub-share-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.pub-share-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--color-text-muted, #8896ab);
}

.pub-share-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pub-metrics-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  background: var(--color-bg-card, #1a2233);
  border: 1px solid var(--color-border, #1e293b);
  color: var(--color-text-muted, #8896ab);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pub-metrics-refresh-btn:hover {
  border-color: var(--color-primary, #3b82f6);
  color: var(--color-primary, #3b82f6);
  background: rgba(59, 130, 246, 0.08);
}

.pub-metrics-refresh-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Light theme overrides */
[data-theme="light"] .pub-metrics-dashboard {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .pub-metric-card {
  background: #fff;
  border-color: #e2e8f0;
}

[data-theme="light"] .pub-metric-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .pub-metric-icon {
  opacity: 0.06;
}

[data-theme="light"] .pub-metrics-refresh-btn {
  background: #fff;
  border-color: #e2e8f0;
}

[data-theme="light"] .pub-share-bar {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .pub-donut-ring + .pub-donut-ring {
  /* handled via inline stroke */
}

[data-theme="light"] .pub-monthly-bar {
  opacity: 0.8;
}

/* Responsive: 2 columns at 768px */
@media (max-width: 768px) {
  .pub-metrics-dashboard {
    padding: 1.25rem;
  }
  .pub-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pub-metrics-grid--wide {
    grid-template-columns: 1fr;
  }
  .pub-metrics-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
}

/* Responsive: 1 column at 480px */
@media (max-width: 480px) {
  .pub-metrics-grid {
    grid-template-columns: 1fr;
  }
  .pub-metric-value {
    font-size: 1.5rem;
  }
}

/* Hide dashboard in reading mode */
body.reading-mode .pub-metrics-dashboard {
  display: none !important;
}

/* Hide dashboard in print */
@media print {
  .pub-metrics-dashboard {
    display: none !important;
  }
}

/* ── Submission Tracker (Kanban Board) ─────────────────────── */
.submission-tracker {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--color-surface, #111827);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 12px;
}

.st-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.st-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text, #e2e8f0);
  margin: 0;
}
.st-add-btn {
  padding: 0.4rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-primary, #3b82f6);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.st-add-btn:hover {
  background: #2563eb;
}

.st-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.st-board::-webkit-scrollbar { height: 6px; }
.st-board::-webkit-scrollbar-track { background: transparent; }
.st-board::-webkit-scrollbar-thumb { background: var(--color-border, #1e293b); border-radius: 3px; }

.st-column {
  min-width: 200px;
  max-width: 240px;
  flex: 1 0 200px;
  background: var(--color-bg, #0a0e17);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}
.st-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  border-top: 3px solid #64748b;
  border-radius: 8px 8px 0 0;
}
.st-column-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text, #e2e8f0);
}
.st-column-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  background: #64748b;
  border-radius: 10px;
}

.st-column-body {
  flex: 1;
  padding: 0.5rem;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 420px;
  transition: background 0.15s;
}

.st-card {
  position: relative;
  padding: 0.625rem 0.75rem;
  background: var(--color-surface, #111827);
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 6px;
  cursor: grab;
  transition: box-shadow 0.15s, opacity 0.15s, transform 0.15s;
}
.st-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transform: translateY(-1px);
}
.st-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text, #e2e8f0);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}
.st-card-journal {
  font-size: 0.75rem;
  color: var(--color-primary, #3b82f6);
  margin-bottom: 0.2rem;
}
.st-card-date {
  font-size: 0.6875rem;
  color: var(--color-text-muted, #8896ab);
  margin-bottom: 0.2rem;
}
.st-card-notes {
  font-size: 0.6875rem;
  color: var(--color-text-dim, #5a6a80);
  line-height: 1.4;
}

.st-card-actions {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.st-card:hover .st-card-actions {
  opacity: 1;
}
.st-card-action-btn {
  padding: 0.15rem 0.3rem;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--color-border, #1e293b);
  border-radius: 4px;
  color: var(--color-text-muted, #8896ab);
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.st-card-action-btn:hover {
  background: var(--color-border, #1e293b);
  color: var(--color-text, #e2e8f0);
}

.st-card-dragging {
  opacity: 0.4;
}
.st-column-dragover {
  background: rgba(59,130,246,0.08);
  border-color: var(--color-primary, #3b82f6);
  border-style: dashed;
}

.st-empty {
  font-size: 0.75rem;
  color: var(--color-text-dim, #5a6a80);
  text-align: center;
  padding: 1.5rem 0.5rem;
  font-style: italic;
}

/* Form inside modal */
.st-form { display: flex; flex-direction: column; gap: 0.5rem; }
.st-form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted, #8896ab);
  margin-bottom: -0.25rem;
}
.st-form-input {
  width: 100%;
  box-sizing: border-box;
}

/* Light theme overrides */
[data-theme="light"] .submission-tracker {
  background: #fff;
  border-color: #e2e8f0;
}
[data-theme="light"] .st-column {
  background: #f8fafc;
  border-color: #e2e8f0;
}
[data-theme="light"] .st-card {
  background: #fff;
  border-color: #e2e8f0;
}
[data-theme="light"] .st-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
[data-theme="light"] .st-card-action-btn {
  border-color: #e2e8f0;
}
[data-theme="light"] .st-card-action-btn:hover {
  background: #f1f5f9;
}
[data-theme="light"] .st-column-dragover {
  background: rgba(59,130,246,0.05);
}

/* Responsive */
@media (max-width: 768px) {
  .st-column {
    min-width: 180px;
    flex: 1 0 180px;
  }
}

/* Hide tracker in reading mode */
body.reading-mode .submission-tracker {
  display: none !important;
}

/* Hide tracker in print */
@media print {
  .submission-tracker {
    display: none !important;
  }
}

/* ===== Version History ===== */

.vh-trigger-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.75rem; border: 1px solid var(--color-border, #1e293b);
  border-radius: 6px; background: var(--color-bg-card, #111827);
  color: var(--color-text-muted, #8896ab); font-size: 0.8125rem;
  cursor: pointer; transition: all 0.15s;
}
.vh-trigger-btn:hover {
  background: var(--color-bg-hover, #1e293b);
  color: var(--color-text, #e2e8f0);
  border-color: var(--color-primary, #3b82f6);
}
.vh-trigger-btn svg { flex-shrink: 0; }

/* Tabs */
.vh-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--color-border, #1e293b);
  margin-bottom: 1rem;
}
.vh-tab {
  padding: 0.5rem 1rem; background: none; border: none;
  color: var(--color-text-muted, #8896ab); font-size: 0.8125rem;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.vh-tab:hover { color: var(--color-text, #e2e8f0); }
.vh-tab-active {
  color: var(--color-primary, #3b82f6);
  border-bottom-color: var(--color-primary, #3b82f6);
  font-weight: 600;
}

/* Timeline */
.vh-timeline { position: relative; padding: 0.5rem 0 0.5rem 0; }

.vh-version-node {
  display: flex; gap: 1rem; padding: 0.75rem 0;
  position: relative;
}
.vh-version-node + .vh-version-node {
  border-top: 1px solid var(--color-border, #1e293b);
}

.vh-timeline-rail {
  width: 56px; flex-shrink: 0; display: flex;
  flex-direction: column; align-items: center;
  position: relative; padding-top: 0.125rem;
}
.vh-timeline-rail::after {
  content: ''; position: absolute; top: 2rem; bottom: -0.75rem;
  left: 50%; width: 2px; background: var(--color-border, #1e293b);
  transform: translateX(-50%);
}
.vh-version-node:last-child .vh-timeline-rail::after { display: none; }

.vh-version-badge {
  display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px;
  font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap; position: relative; z-index: 1;
}
.vh-badge-major {
  background: rgba(34,197,94,0.15); color: #22c55e;
  border: 1px solid rgba(34,197,94,0.3);
}
.vh-badge-minor {
  background: rgba(59,130,246,0.15); color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.3);
}
.vh-badge-patch {
  background: rgba(148,163,184,0.15); color: #94a3b8;
  border: 1px solid rgba(148,163,184,0.3);
}

.vh-version-body { flex: 1; min-width: 0; }
.vh-version-header {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; color: var(--color-text, #e2e8f0);
}
.vh-version-meta {
  font-size: 0.75rem; color: var(--color-text-dim, #5a6a80);
  margin-top: 0.25rem;
}
.vh-version-summary {
  font-size: 0.8125rem; color: var(--color-text-muted, #8896ab);
  margin: 0.375rem 0 0.5rem; line-height: 1.5;
}
.vh-word-delta-pos { color: #22c55e; font-weight: 600; }
.vh-word-delta-neg { color: #ef4444; font-weight: 600; }

.vh-current-badge {
  display: inline-block; padding: 0.0625rem 0.375rem; border-radius: 4px;
  font-size: 0.625rem; font-weight: 700; text-transform: uppercase;
  background: rgba(59,130,246,0.15); color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.3);
}

.vh-restore-btn {
  padding: 0.25rem 0.625rem; border: 1px solid var(--color-border, #1e293b);
  border-radius: 4px; background: var(--color-bg-card, #111827);
  color: var(--color-text-muted, #8896ab); font-size: 0.75rem;
  cursor: pointer; transition: all 0.15s;
}
.vh-restore-btn:hover {
  border-color: var(--color-primary, #3b82f6);
  color: var(--color-primary, #3b82f6);
  background: rgba(59,130,246,0.08);
}

/* Diff Viewer */
.vh-diff-selector {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem; flex-wrap: wrap;
  font-size: 0.8125rem; color: var(--color-text-muted, #8896ab);
}
.vh-diff-selector select {
  padding: 0.3rem 0.5rem; border: 1px solid var(--color-border, #1e293b);
  border-radius: 4px; background: var(--color-bg-card, #111827);
  color: var(--color-text, #e2e8f0); font-size: 0.8125rem;
}

.vh-diff-stats {
  font-size: 0.75rem; padding: 0.375rem 0.75rem; margin-bottom: 0.5rem;
  background: var(--color-bg-card, #111827); border-radius: 4px;
  border: 1px solid var(--color-border, #1e293b);
}

.vh-diff-container {
  display: flex; gap: 2px; border: 1px solid var(--color-border, #1e293b);
  border-radius: 6px; overflow: hidden;
}
.vh-diff-pane {
  flex: 1; overflow-y: auto; max-height: 400px;
  font-family: var(--font-mono, monospace); font-size: 0.75rem;
  line-height: 1.6; background: var(--color-bg, #0a0e17);
  padding: 0;
}
.vh-diff-pane > div {
  padding: 0 0.5rem; white-space: pre-wrap; word-break: break-word;
  min-height: 1.6em;
}
.vh-diff-pane-header {
  padding: 0.375rem 0.5rem; font-size: 0.6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--color-bg-card, #111827);
  color: var(--color-text-dim, #5a6a80);
  border-bottom: 1px solid var(--color-border, #1e293b);
  position: sticky; top: 0; z-index: 1;
}

.vh-diff-add { background: rgba(34,197,94,0.12); color: #86efac; }
.vh-diff-del { background: rgba(239,68,68,0.12); color: #fca5a5; }
.vh-diff-placeholder { opacity: 0; }

/* Light theme overrides */
[data-theme="light"] .vh-trigger-btn {
  background: #fff; border-color: #e2e8f0; color: #64748b;
}
[data-theme="light"] .vh-trigger-btn:hover {
  background: #f1f5f9; color: #334155;
}
[data-theme="light"] .vh-diff-add { background: rgba(34,197,94,0.1); color: #166534; }
[data-theme="light"] .vh-diff-del { background: rgba(239,68,68,0.1); color: #991b1b; }
[data-theme="light"] .vh-diff-selector select {
  background: #fff; border-color: #e2e8f0; color: #334155;
}
[data-theme="light"] .vh-restore-btn {
  background: #fff; border-color: #e2e8f0; color: #64748b;
}
[data-theme="light"] .vh-current-badge {
  background: rgba(59,130,246,0.1); color: #2563eb;
}

/* Responsive: stack diff panes vertically on narrow screens */
@media (max-width: 768px) {
  .vh-diff-container { flex-direction: column; }
  .vh-diff-pane { max-height: 280px; }
  .vh-diff-selector { flex-direction: column; align-items: flex-start; }
}
