/* ============================================
   《腌笃鲜》维基百科 - Components
   ============================================ */

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 32px;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: opacity var(--transition-normal),
              visibility var(--transition-normal),
              transform var(--transition-normal),
              box-shadow var(--transition-normal),
              border-color var(--transition-normal);
  opacity: 0;
  visibility: hidden;
  z-index: 100;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent-fire);
}

.back-to-top svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
  transition: fill var(--transition-fast);
}

.back-to-top:hover svg {
  fill: var(--accent-fire);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.sidebar-toggle:hover {
  border-color: var(--accent-fire);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
  fill: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 150;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  flex-direction: column;
  gap: 16px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-fire);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.sidebar-search {
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  background: var(--bg-page);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.sidebar-search input::placeholder {
  color: var(--text-secondary);
}

.sidebar-search input:focus {
  border-color: var(--accent-fire);
}

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

.toc-search-results {
  padding: 0 10px 10px;
}

.toc-search-results[hidden] {
  display: none;
}

.toc-search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-search-count,
.toc-search-empty {
  margin: 0;
  padding: 8px 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.toc-search-empty {
  padding-top: 18px;
  text-align: center;
}

.toc-search-result {
  display: block;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.toc-search-result:hover,
.toc-search-result:focus-visible {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toc-search-result strong,
.toc-search-result span {
  display: block;
}

.toc-search-result small {
  display: block;
  margin-bottom: 2px;
  overflow: hidden;
  color: var(--accent-fire);
  font-size: 10.5px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-search-result strong {
  margin-bottom: 3px;
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.45;
}

.toc-search-result span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11.5px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.toc-search-result mark {
  padding: 0 1px;
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* 单例词条提示卡：不承载点击操作，链接本身负责跨篇导航。 */
.term-tooltip {
  position: fixed;
  z-index: 1200;
  display: grid;
  width: min(300px, calc(100vw - 24px));
  padding: 13px 15px 14px 17px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  background-image: var(--texture-paper);
  box-shadow: var(--shadow-float);
  color: var(--text-body);
  pointer-events: none;
}

.term-tooltip::before {
  content: '';
  position: absolute;
  inset: 10px auto 10px 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-gold);
}

.term-tooltip[hidden] {
  display: none;
}

/* 有图词条：左图右文双列；无图词条保持原有纯文本单列 */
.term-tooltip.has-icon {
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: 11px;
  align-items: start;
}

.term-tooltip-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  padding: 3px;
  border: 1px solid var(--border-light);
  border-radius: 9px;
  background: var(--bg-page);
}

.term-tooltip-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.term-tooltip-kind {
  margin-bottom: 2px;
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.4;
}

.term-tooltip-title {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.term-tooltip-summary {
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}

@media (hover: none) and (pointer: coarse) {
  .term-tooltip {
    display: none !important;
  }
}

.update-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 10px;
  margin: 16px 0 18px;
}

body.sidebar-open {
  overflow: hidden;
}

.update-summary-item {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  transition: transform var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.update-summary-item.has-object-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  grid-template-areas:
    "head head"
    "copy media"
    "tags media";
  column-gap: 12px;
  row-gap: 7px;
  align-content: start;
}

.update-summary-item.has-object-media > .update-summary-head {
  grid-area: head;
}

.update-summary-item.has-object-media > p {
  grid-area: copy;
}

.update-summary-item.has-object-media > .keyword-tags {
  grid-area: tags;
  margin-top: 0;
}

.update-summary-item.has-object-media > .fig-card {
  grid-area: media;
  float: none;
  align-self: start;
  width: 84px;
  margin: 2px 0 0;
}

.update-summary-item.has-object-media > .fig-card .fig-card-media img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, 0.22));
}

.update-summary-item:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-gold-rgb), 0.45);
  box-shadow: var(--shadow-card-hover);
}

.update-summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.update-summary-head h4 {
  flex: 1;
  min-width: 0;
}

.update-summary-item h4 {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.4;
}

.update-summary-item p {
  margin: 0;
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.65;
}

.update-kind {
  flex: none;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.update-kind-new,
.update-kind-current {
  background: var(--color-new-bg);
  color: var(--color-new);
}

.update-kind-recap {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.update-summary-note {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
}

.update-summary-note strong {
  color: var(--accent-fire);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.keyword-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.keyword-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid rgba(var(--accent-gold-rgb), 0.42);
  border-radius: 999px;
  color: var(--accent-gold);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

.version-cell {
  color: var(--color-adjust);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.version-cell strong {
  display: inline-flex;
  padding: 2px 7px;
  border: 1px solid rgba(var(--accent-gold-rgb), 0.42);
  border-radius: 999px;
  color: inherit;
  background: var(--color-adjust-bg);
  font-size: 12px;
}

.keyword-cell .keyword-tags {
  margin-top: 0;
  min-width: 150px;
}

.faq-list {
  margin: 16px 0 28px;
  border-top: 1px solid var(--border-light);
}

/* 「展开全部」内嵌于 H3 标题行右侧；章序 ::before 与标题文本靠左，按钮推至行尾 */
.faq-heading {
  display: flex;
  align-items: baseline;
}

.faq-heading .faq-toggle-all {
  margin-left: auto;
  flex-shrink: 0;
}

.faq-toggle-all {
  padding: 4px 12px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.faq-toggle-all:hover {
  color: var(--accent-fire);
  border-color: var(--accent-fire);
}

.faq-item {
  border-bottom: 1px solid var(--border-light);
}

.faq-item summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 4px;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary:hover {
  color: var(--accent-fire);
  background: var(--bg-hover);
}

.faq-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--accent-fire);
  border-radius: 999px;
  color: var(--accent-fire);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.faq-question {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.65;
}

.faq-chevron {
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--transition-fast);
}

.faq-item[open] .faq-chevron {
  transform: rotate(225deg);
}

.faq-answer {
  padding: 0 46px 14px;
  color: var(--text-secondary);
}

.faq-answer p {
  margin: 0;
  color: inherit;
}

.jieyun-catalog {
  margin: 18px 0 24px;
}

.jieyun-catalog [hidden] {
  display: none !important;
}

.jieyun-filter {
  padding: 9px 11px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
}

.jieyun-filter-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.jieyun-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.jieyun-filter-input {
  width: 100%;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.jieyun-filter-input:focus {
  border-color: var(--accent-fire);
  box-shadow: 0 0 0 3px rgba(var(--accent-fire-rgb), 0.12);
}

.jieyun-filter-clear {
  padding: 8px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

.jieyun-filter-clear:hover:not(:disabled) {
  border-color: var(--accent-fire);
  color: var(--accent-fire);
}

.jieyun-filter-clear:disabled {
  opacity: 0.42;
  cursor: default;
}

.jieyun-filter-status {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  white-space: nowrap;
}

.jieyun-filter-empty {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.jieyun-table-outer {
  margin: 10px 0 0;
}

.jieyun-card-list {
  display: none;
}

.jieyun-filter-empty {
  margin-top: 10px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
}

.jieyun-catalog-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.jieyun-expand-toggle {
  padding: 7px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.jieyun-expand-toggle:hover,
.jieyun-expand-toggle:focus-visible {
  border-color: var(--accent-fire);
  background: var(--bg-hover);
  color: var(--accent-fire);
}

.jieyun-card {
  padding: 14px 15px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.jieyun-card-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border-light);
}

.jieyun-card-kicker {
  flex: none;
  color: var(--accent-gold);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.md-body .jieyun-card h5 {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--text-primary);
  font-size: 17px;
  line-height: 1.45;
}

.md-body .jieyun-card-verse {
  margin: 11px 0 10px;
  color: var(--text-secondary);
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.7;
}

.md-body .jieyun-card-completion {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  margin: 0;
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.65;
}

.jieyun-card-completion strong {
  color: var(--accent-fire);
  font-size: 12px;
  white-space: nowrap;
}

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-fire), var(--accent-gold));
  z-index: 9999;
  transition: width 0.1s linear;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: #abb2bf;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  font-family: inherit;
  line-height: 1.5;
}

.md-body pre:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.copy-btn.copied {
  color: #98c379;
  border-color: rgba(152, 195, 121, 0.4);
}

.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              color var(--transition-fast);
  color: var(--text-secondary);
}

.theme-toggle:hover {
  border-color: var(--accent-fire);
  box-shadow: var(--shadow-card-hover);
  color: var(--accent-fire);
  transform: translateY(-2px);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

@media (max-width: 768px) {
  .theme-toggle {
    top: 12px;
    right: 12px;
  }
}

/* ============================================
   V1: 品牌化加载（印章脉冲 + 金环）
   ============================================ */

.loading-seal {
  position: relative;
  width: 46px;
  height: 46px;
  animation: sealPulse 1.8s ease-in-out infinite;
}

.loading-seal img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.loading-seal::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 1.5px dashed rgba(var(--accent-gold-rgb), 0.55);
  border-radius: 14px;
  animation: spin 7s linear infinite;
}

@keyframes sealPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.92); }
}

/* ============================================
   V1.1: 金色降级为发丝线，标签/版本回归中性
   ============================================ */

.keyword-tag {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

/* 类型词色彩语义：战斗/BOSS 系朱红，人物/精怪系黛青（--color-fix 色值），其余保持中性灰 */
.keyword-tag-fire {
  border-color: color-mix(in srgb, var(--accent-fire) 48%, transparent);
  color: var(--accent-fire);
}

.keyword-tag-info {
  border-color: color-mix(in srgb, var(--color-fix) 52%, transparent);
  color: var(--color-fix);
}

.version-cell strong {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.update-summary-item:hover {
  border-color: var(--border-light);
}
