html {
  font-size: 14px;
  height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 14px;
  }
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow:
    0 0 0 0.1rem white,
    0 0 0 0.25rem #258cfb;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

/* 顶栏搜索：单行高度，按钮文字横向不换行 */
.site-header-search {
  flex-wrap: nowrap;
}

.site-header-search .form-control {
  line-height: 1.25;
}

.site-header-search .btn {
  writing-mode: horizontal-tb;
}

.admin-article-table .admin-article-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ------------------------------------------------------------------ */
/* 文章正文：简洁文档风（居中、留白、中英混排无衬线）                  */
/* ------------------------------------------------------------------ */

.article-shell {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

/* 正文 + 右侧问答导航 */
.article-layout {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.article-layout__main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 860px;
}

/* 右侧轨道：大屏随文 sticky；小屏贴右缘固定，避免挡正文 */
.qa-nav-rail {
  flex: 0 0 40px;
  width: 40px;
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  z-index: 20;
}

.qa-nav-rail__scroller {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: inherit;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0;
  scrollbar-width: thin;
}

.qa-nav-rail__line {
  position: absolute;
  left: 50%;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  margin-left: -1px;
  background: #d0d7de;
  border-radius: 1px;
  pointer-events: none;
}

.qa-nav-rail__markers {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 0.35rem 0;
}

.qa-nav-rail__marker {
  flex-shrink: 0;
  width: 11px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  /* 未定位到该问：灰色、缩小 */
  background: #aeb8c2;
  cursor: pointer;
  transform: scale(0.68);
  transform-origin: center center;
  opacity: 0.92;
  transition:
    background-color 0.22s ease,
    transform 0.22s ease,
    opacity 0.22s ease;
}

.qa-nav-rail__marker:not(.qa-nav-rail__marker--active):hover,
.qa-nav-rail__marker:not(.qa-nav-rail__marker--active):focus-visible {
  background: #949da8;
  transform: scale(0.78);
  opacity: 1;
  outline: none;
}

/* 当前滚动到的问答：黑色、正常尺寸 */
.qa-nav-rail__marker--active {
  background: #1f2328;
  transform: scale(1);
  opacity: 1;
}

.qa-nav-rail__marker--active:hover,
.qa-nav-rail__marker--active:focus-visible {
  background: #24292f;
  transform: scale(1);
  opacity: 1;
}

.qa-nav-rail__tooltip {
  position: fixed;
  z-index: 1095;
  max-width: min(320px, calc(100vw - 48px));
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #24292f;
  background: #fff;
  border-radius: 12px;
  box-shadow:
    0 4px 24px rgba(31, 35, 40, 0.18),
    0 0 0 1px rgba(208, 215, 222, 0.6);
  pointer-events: none;
}

.qa-nav-rail__tooltip--visible {
  animation: qa-nav-tooltip-in 0.12s ease-out;
}

@keyframes qa-nav-tooltip-in {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 小屏：轨道贴右，正文留空 */
@media (max-width: 767.98px) {
  .article-layout {
    padding-right: 36px;
  }

  .qa-nav-rail {
    position: fixed;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    flex: none;
    width: 32px;
    max-height: min(72vh, 560px);
  }

  .qa-nav-rail__markers {
    gap: 1rem;
  }

  .qa-nav-rail__marker {
    width: 10px;
    min-height: 20px;
  }
}

/* 全屏问答预览（小屏：竖向列表 + 上下滚动） */
.qa-nav-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
}

.qa-nav-mobile-overlay[hidden] {
  display: none !important;
}

.qa-nav-mobile-overlay__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.4);
}

.qa-nav-mobile-overlay__sheet {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
}

.qa-nav-mobile-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: calc(0.65rem + env(safe-area-inset-top, 0px)) 1rem 0.65rem;
  background: #fff;
  border-bottom: 1px solid #d0d7de;
}

.qa-nav-mobile-overlay__title {
  font-size: 1rem;
  font-weight: 600;
  color: #24292f;
}

.qa-nav-mobile-overlay__close {
  border: 0;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  color: #57606a;
  cursor: pointer;
  border-radius: 6px;
}

.qa-nav-mobile-overlay__close:focus-visible {
  outline: 2px solid #0969da;
}

.qa-nav-mobile-overlay__list-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qa-nav-mobile-overlay__list {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.qa-nav-mobile-overlay__item {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #d0d7de;
  background: #fff;
  padding: 1rem 1.15rem;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.12s ease;
}

.qa-nav-mobile-overlay__item:active {
  background: #f6f8fa;
}

.qa-nav-mobile-overlay__item:focus-visible {
  outline: 2px solid #0969da;
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

.qa-nav-mobile-overlay__item:last-child {
  border-bottom: 0;
}

.qa-nav-mobile-overlay__preview {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #24292f;
}

body.qa-nav-mobile-overlay-open {
  overflow: hidden;
}

.article-title-display {
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 600;
  line-height: 1.35;
  color: #24292f;
  letter-spacing: -0.02em;
}

.admin-shell {
  display: flex;
  flex: 1 0 auto;
  min-height: calc(100vh - 117px);
  min-height: calc(100dvh - 117px);
  background: #f6f8fb;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex: 0 0 220px;
  flex-direction: column;
  align-self: flex-start;
  min-height: calc(100vh - 117px);
  min-height: calc(100dvh - 117px);
  padding: 1.5rem 1rem;
  color: #334155;
  background: #fff;
  border-right: 1px solid #e2e8f0;
}

.admin-sidebar__title {
  padding: 0 0.75rem 0.75rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-sidebar__nav {
  gap: 0.25rem;
}

.admin-sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  color: #475569;
  text-decoration: none;
  border-radius: 0.5rem;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

.admin-sidebar__link:hover {
  color: #1d4ed8;
  background: #f1f5f9;
}

.admin-sidebar__link.active {
  color: #1d4ed8;
  font-weight: 600;
  background: #eff6ff;
}

.admin-sidebar__link i {
  width: 1.1rem;
  font-size: 1rem;
  text-align: center;
}

.admin-sidebar__button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.admin-sidebar__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.admin-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2rem;
}

.admin-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.attachment-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.attachment-preview-button {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.attachment-preview-button:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.35);
  outline-offset: 2px;
  border-radius: 0.375rem;
}

.attachment-image-preview {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(15, 23, 42, 0.88);
}

.attachment-image-preview__image {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
}

.attachment-image-preview__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.attachment-video-preview {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(15, 23, 42, 0.88);
}

.attachment-video-container {
  width: 100%;
  max-width: 960px;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.35);
  background: #000;
}

.attachment-video-preview__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
}

.attachment-edit-modal {
  z-index: 3100;
}

.modal-backdrop.attachment-edit-backdrop {
  z-index: 3050;
}

.attachment-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 92px;
  padding: 0.75rem;
  color: #64748b;
  text-align: center;
  background: #fff;
  border: 2px dashed #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

.attachment-drop-zone:hover,
.attachment-drop-zone:focus-visible,
.attachment-drop-zone.is-paste-ready,
.attachment-drop-zone.is-dragging {
  color: #0d6efd;
  background: #f0f7ff;
  border-color: #0d6efd;
  outline: 0;
}

.attachment-drop-zone.is-paste-ready [data-drop-zone-prompt] {
  font-weight: 600;
}

.attachment-drop-zone--large {
  min-height: 130px;
}

.attachment-drop-zone small {
  color: #94a3b8;
}

.attachment-queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 190px;
  margin-top: 0.5rem;
  overflow-y: auto;
}

.attachment-queue-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.4rem 0.5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
}

.attachment-queue-item__details {
  flex: 1 1 auto;
  min-width: 0;
}

.attachment-queue-item__name {
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-queue-item__meta {
  color: #64748b;
  font-size: 0.7rem;
}

.attachment-queue-item__progress {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.25rem;
}

.attachment-queue-item__progress .progress {
  flex: 1 1 auto;
  height: 0.35rem;
}

.attachment-queue-item__progress-label {
  flex: 0 0 2.25rem;
  color: #475569;
  font-size: 0.65rem;
  text-align: right;
}

.attachment-queue-item__remove {
  flex: 0 0 auto;
  padding: 0.15rem 0.3rem;
  text-decoration: none;
}

.attachment-queue-item.is-uploading {
  border-color: #93c5fd;
  background: #eff6ff;
}

.attachment-queue-item.is-cancelled {
  border-color: #cbd5e1;
  background: #f8fafc;
  opacity: 0.85;
}

@media (max-width: 767.98px) {
  .admin-shell {
    display: block;
  }

  .admin-sidebar {
    position: static;
    display: block;
    min-height: 0;
    padding: 0.75rem;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
  }

  .admin-sidebar__title,
  .admin-sidebar__footer {
    display: none;
  }

  .admin-sidebar__nav {
    flex-direction: row !important;
    overflow-x: auto;
  }

  .admin-sidebar__link {
    flex: 0 0 auto;
    padding: 0.6rem 0.75rem;
  }

  .admin-main {
    padding: 1.25rem 1rem;
  }
}

/* Full-screen Editor Overlay */
.admin-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  background-color: #f8f9fa;
  display: flex;
  flex-direction: column;
  animation: overlayFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.admin-editor-overlay .overlay-body {
  height: calc(100vh - 57px);
}

.admin-editor-overlay .editor-form-panel {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.admin-editor-overlay .editor-form-panel .card {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

.admin-editor-overlay .editor-form-panel .card-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

.admin-editor-overlay #overlay-article-form {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
}

.admin-editor-overlay .attachments-sidebar-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

.admin-editor-overlay #sidebar-list-container {
  min-width: 0;
  overflow-x: hidden;
}

.admin-editor-overlay #sidebar-attachment-list,
.admin-editor-overlay .attachment-item,
.admin-editor-overlay .attachment-item .card-body {
  min-width: 0;
  max-width: 100%;
}

.admin-editor-overlay .attachment-item .min-w-0 {
  min-width: 0 !important;
}

.admin-editor-overlay .attachment-item {
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.admin-editor-overlay .attachment-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(13, 110, 253, 0.2) !important;
}

.btn-xs {
  padding: 0.15rem 0.35rem;
  font-size: 0.75rem;
  border-radius: 4px;
}

.alert-sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

body.overflow-hidden {
  overflow: hidden !important;
}

/* Admin Tags Popover styles */
.admin-article-tags-container {
  min-height: 24px;
}

.admin-tag-edit-btn {
  color: #6c757d;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.admin-tag-edit-btn:hover {
  color: #0d6efd;
  opacity: 1;
  transform: scale(1.1);
}

#tags-popover {
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

#tags-popover-list::-webkit-scrollbar {
  width: 4px;
}

#tags-popover-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

#tags-popover-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

#tags-popover-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

#tags-popover-list .btn-check:checked + .btn-outline-secondary {
  background-color: rgba(13, 110, 253, 0.1) !important;
  color: #0d6efd !important;
  border-color: #0d6efd !important;
  font-weight: 500;
}

/* Admin Publication Status Toggle Button */
.admin-toggle-publish-btn {
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.admin-toggle-publish-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.admin-toggle-publish-btn:active {
  transform: scale(0.95);
}

/* Article body Plyr video player styling */
.article-body .plyr {
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1);
  margin: 1.5rem 0;
}

/* 个人创作与拾录共用导航，创作使用独立的阅读主题。 */
.section-nav { display: flex; gap: .25rem; margin-right: auto; }
.section-nav a { color: #68716e; text-decoration: none; padding: .65rem 1rem; border-radius: 999px; font-size: .95rem; }
.section-nav a.active { background: #e9ede6; color: #304f41; font-weight: 600; }
.section-nav a:hover { background: #eef0eb; }

.journal-theme > header .navbar { background: var(--journal-bg) !important; box-shadow: none; border-color: #dedfd5 !important; }
.journal-hero { position: relative; padding: 5rem 0 4rem; border-bottom: 1px solid #d9ddd2; margin-bottom: 2.5rem; }
.journal-eyebrow { letter-spacing: .2em; font-size: .72rem; color: #75816f; margin-bottom: 1.6rem; }
.journal-hero h1 { font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif; font-size: clamp(2.2rem, 5.5vw, 4.6rem); font-weight: 500; line-height: 1.35; letter-spacing: -.04em; margin-bottom: 1.5rem; }
.journal-hero h1 span { color: #718561; }
.journal-hero > p { color: #737b70; line-height: 1.9; }
.journal-signature { color: #738366; margin-top: 2.5rem; font-size: .85rem; }
.journal-signature span { display: inline-block; font-size: 1.7rem; vertical-align: middle; margin-right: .7rem; }
.journal-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.journal-card { overflow: hidden; border: 1px solid #e0e2d8; border-radius: 14px; background: #fffefa; min-width: 0; transition: border-color .2s, transform .2s; }
.journal-card:hover { border-color: #9fac93; transform: translateY(-3px); }
.journal-card-content { padding: 1.8rem; }
.journal-card-image { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #e9eade; }
.journal-card-image img { width: 100%; height: 100%; object-fit: cover; }
.journal-card-meta { font-size: .75rem; color: #7a8375; letter-spacing: .04em; margin-bottom: .8rem; }
.journal-card-meta a { color: inherit; text-decoration: none; }
.journal-card-title { display: block; color: #304333; font-family: Georgia, "Songti SC", serif; font-size: 1.5rem; font-weight: 600; line-height: 1.5; text-decoration: none; overflow-wrap: anywhere; }
.journal-card-title:hover { color: #698454; }
.journal-card-summary { font-size: .92rem; color: #777d72; line-height: 1.9; margin: 1rem 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.journal-theme .badge.text-bg-primary { background-color: #5b7451 !important; }
.journal-theme .badge.text-bg-light { background: #f0f1e9 !important; border-color: #e0e3d8 !important; font-weight: 400; }
.article-tag-filter a { min-height: 32px; display: inline-flex; align-items: center; gap: .3rem; }
.journal-empty { padding: 3rem 1rem; text-align: center; color: #798373; border: 1px dashed #d6dccd; border-radius: 12px; }
.journal-empty a { color: #536e47; }
.journal-cover { display: block; width: 100%; max-height: 560px; object-fit: contain; margin-bottom: 2rem; border-radius: 10px; }
.journal-article .article-title-display { font-family: Georgia, "Songti SC", serif; line-height: 1.5; }
.journal-article .article-shell { background: transparent; }

.journal-feed { padding-bottom: 3rem; }
@media (max-width: 575px) {
    .journal-hero { padding: 2.5rem 0 2rem; margin-bottom: 1.75rem; }
    .journal-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .journal-card-content { padding: 1.3rem; }
    .section-nav a { padding: .7rem .85rem; }
    .site-header-search { width: 100%; }
    .site-header-search input[type="search"] { min-width: 0 !important; width: 100%; }
    .journal-card-title { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
    .journal-card { transition: none; }
    .journal-card:hover { transform: none; }
}

.article-rating-stars {
  display: inline-flex;
  vertical-align: middle;
}

.article-rating-star {
  position: relative;
  display: inline-block;
  width: 2.25rem;
  height: 2.25rem;
}

.article-rating-star svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.article-rating-star-outline {
  fill: #f1f3f5;
  stroke: #8b929a;
  stroke-width: 1;
}

.article-rating-star-fill {
  fill: #e6a000;
  stroke: #a66c00;
  stroke-width: 1;
  clip-path: inset(0 calc(100% - var(--star-fill, 0%)) 0 0);
}

.article-rating-half {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.article-rating-half-right {
  left: 50%;
}

.article-rating-half:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 1px;
  border-radius: 3px;
}

.article-rating-form[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.65;
}
