:root {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 时间戳：等宽/打字机字体，归档记录质感 */
.time-stamp {
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Roboto Mono", ui-monospace, monospace;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.font-serif,
.archive-prose {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", Georgia, serif;
}

/* 详情正文排版：让段落/图片/引用更舒展，避免过于密集 */
/* 段落间距：正文里的 <p> 之间留白。豆瓣正文常被 .reply-content/.markdown 包多层，
   用后代选择器命中任意层级的 <p>；单向 margin-top 保证相邻段只留一次间距 */
.archive-prose p {
  margin-top: 1.25em;
  margin-bottom: 0;
}

.archive-prose p:first-child {
  margin-top: 0;
}

/* 清理豆瓣外层包装可能自带的默认 margin，避免间距错乱 */
.archive-prose .reply-content,
.archive-prose .markdown {
  margin: 0;
}

.archive-prose img {
  max-width: 100%;
  height: auto;
  margin: 1.25em auto;
  border-radius: 0.75rem;
  display: block;
}

.archive-prose blockquote {
  margin: 1.25em 0;
  padding-left: 1em;
  border-left: 3px solid rgb(214 211 209);
  color: rgb(120 113 108);
}

.archive-prose a {
  color: rgb(127 29 29);
  text-decoration: underline;
  text-underline-offset: 3px;
}

body {
  background-image: radial-gradient(rgba(120, 100, 65, 0.07) 0.65px, transparent 0.65px);
  background-size: 9px 9px;
}

/* 筛选整体刷新 #archive-grid 时，禁用浏览器滚动锚定，避免内容高度变化导致页面跳动 */
#archive-grid {
  overflow-anchor: none;
}
#archive-grid article,
#archive-grid .card-chunk {
  overflow-anchor: none;
}

.paper-shadow {
  box-shadow: 0 1px 1px rgba(52, 42, 27, 0.03), 0 14px 35px rgba(52, 42, 27, 0.055);
}

.stat-cell {
  min-height: 6.8rem;
  padding: 1.25rem 1.5rem;
  border-right: 1px solid rgb(231 229 228);
}

.stat-cell:last-child {
  border-right: 0;
}

.stat-cell span,
.field-label {
  display: block;
  color: rgb(120 113 108);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.stat-cell strong {
  display: block;
  margin-top: 0.45rem;
  color: rgb(41 37 36);
  font-family: "Songti SC", "STSong", serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}

.field-input {
  width: 100%;
  margin-top: 0.5rem;
  border: 1px solid rgb(214 211 209);
  border-radius: 0.75rem;
  background: rgb(255 253 248);
  padding: 0.65rem 0.75rem;
  color: rgb(41 37 36);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field-input:focus {
  border-color: rgb(153 27 27);
  box-shadow: 0 0 0 3px rgb(254 226 226);
}

.filter-option {
  cursor: pointer;
}

.filter-option input {
  position: absolute;
  opacity: 0;
}

.filter-option span {
  display: block;
  border-radius: 0.6rem;
  padding: 0.45rem 0.3rem;
  text-align: center;
  color: rgb(120 113 108);
}

.filter-option input:checked + span {
  background: rgb(255 253 248);
  color: rgb(127 29 29);
  box-shadow: 0 1px 3px rgba(41, 37, 36, 0.12);
}

/* 侧栏「当前筛选」小标签 */
.af-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.5rem;
}

.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  border: 1px solid rgb(214 211 209);
  border-radius: 9999px;
  background: rgb(255 253 248);
  padding: 0.28rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.1;
  color: rgb(127 29 29);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.af-chip:hover {
  border-color: rgb(153 27 27);
  background: rgb(254 242 242);
}
.af-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1rem;
  width: 1rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  line-height: 1;
  color: rgb(168 162 158);
  transition: color 150ms ease, background 150ms ease;
}
.af-chip:hover .af-x {
  color: #fff;
  background: rgb(153 27 27);
}

.page-link {
  border-radius: 0.75rem;
  padding: 0.65rem 0.8rem;
  color: rgb(127 29 29);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 150ms ease;
}

.page-link:hover {
  background: rgb(254 242 242);
}

.page-link.is-disabled {
  color: rgb(168 162 158);
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 180ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

@media (max-width: 639px) {
  .stat-cell {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid rgb(231 229 228);
  }

  .stat-cell:last-child {
    border-bottom: 0;
  }
}

/* ===== 列表摘要折叠：固定高度 + 底部渐变蒙版 + 展开/收起 ===== */
.excerpt-collapse {
  position: relative;
}

.excerpt-body {
  overflow: hidden;
  max-height: 5.25rem; /* 约 3 行（leading-7 × 3） */
  transition: max-height 220ms ease;
  -webkit-mask-image: none;
  mask-image: none;
}

/* 短内容无需折叠：完全展开并隐藏蒙版按钮 */
.excerpt-collapse[data-state="none"] .excerpt-body {
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

.excerpt-collapse[data-state="none"] .excerpt-mask {
  display: none;
}

.excerpt-collapse[data-state="open"] .excerpt-body {
  max-height: 120rem; /* 展开时给足高度 */
}

/* 折叠时底部蒙版：从背景色渐变到底部，营造“渐隐”效果 */
.excerpt-collapse[data-state="collapsed"] .excerpt-body {
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

/* 下箭头蒙版按钮，覆盖在渐变区域下方 */
.excerpt-mask {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.15rem 0.4rem;
  border: none;
  background: transparent;
  color: rgb(127 29 29);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms ease;
  opacity: 0;
}

.excerpt-collapse[data-state="collapsed"] .excerpt-mask,
.excerpt-collapse[data-state="open"] .excerpt-mask {
  opacity: 1;
}

/* 折叠时显示「展开」，展开时显示「收起」 */
.excerpt-mask-label {
  display: inline-block;
}
.excerpt-mask-label::after {
  content: "展开";
}
.excerpt-collapse[data-state="open"] .excerpt-mask-label::after {
  content: "收起";
}

/* 隐藏滚动条但保留滚动能力 */
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* 那年今日 · 年份横向导航 */
.year-nav {
  background: rgb(245 245 244); /* stone-100 */
  color: rgb(87 83 78);         /* stone-600 */
}
.year-nav:hover {
  background: rgb(254 242 242); /* red-50 */
  color: rgb(153 27 27);        /* red-800 */
}
.year-nav.is-active {
  background: rgb(153 27 27);   /* red-800 */
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.excerpt-arrow {
  width: 1.05rem;
  height: 1.05rem;
  transition: transform 220ms ease;
}

.excerpt-collapse[data-state="open"] .excerpt-arrow {
  transform: rotate(180deg);
}

/* 折叠正文里的段落间距（与详情页统一） */
.excerpt-body .reply-content,
.excerpt-body .markdown {
  margin: 0;
}

.excerpt-body p {
  margin-top: 1.25em;
  margin-bottom: 0;
}

.excerpt-body p:first-child {
  margin-top: 0;
}

.excerpt-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
  margin: 1em auto;
  display: block;
}

/* 右下角条数悬浮（滚动时显示，停止滚动后隐藏） */
#page-indicator {
  position: fixed;
  right: 1.25rem;
  bottom: 4.75rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgb(214 211 209);
  border-radius: 9999px;
  background: rgb(255 253 248 / 0.92);
  color: rgb(127 29 29);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
  backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
#page-indicator.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#page-indicator .pi-cur {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.05;
  color: rgb(127 29 29);
}
#page-indicator .pi-total {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.55rem;
  font-weight: 600;
  line-height: 1;
  color: rgb(120 113 108);
  font-variant-numeric: tabular-nums;
}

/* 回到顶部悬浮按钮 */
#back-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: rgb(127 29 29);
  color: rgb(253 242 242);
  box-shadow: 0 6px 18px rgb(127 29 29 / 0.35);
  cursor: pointer;
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease, background 150ms ease;
}
#back-top svg {
  width: 1.4rem;
  height: 1.4rem;
}
#back-top:hover {
  background: rgb(153 27 27);
}
#back-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== 详情页讨论串时间线 ===== */
.thread-section {
  padding: 1.25rem 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid rgb(231 229 228);
  background: rgb(250 249 247);
}

.thread-title {
  margin-bottom: 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(168 162 158);
}

.thread-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-left: 0.75rem;
}

/* 左侧竖线 */
.thread-timeline::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.55rem;
  bottom: 0.55rem;
  width: 2px;
  background: linear-gradient(to bottom, rgb(231 229 228), rgb(214 211 209), rgb(231 229 228));
  border-radius: 9999px;
}

.thread-node {
  position: relative;
  display: block;
  padding: 0.55rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid rgb(231 229 228);
  background: rgb(255 253 248);
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.thread-node:hover {
  border-color: rgb(252 165 165);
  background: rgb(254 242 242);
  transform: translateX(2px);
}

.thread-node--direct {
  border-color: rgb(254 202 202);
  background: rgb(255 251 249);
}

.thread-node--direct::before {
  content: "";
  position: absolute;
  left: -0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: rgb(153 27 27);
  border: 2px solid rgb(255 253 248);
  box-shadow: 0 0 0 1px rgb(254 202 202);
}

.thread-node__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: rgb(120 113 108);
}

.thread-node__floor {
  font-weight: 700;
  color: rgb(127 29 29);
}

.thread-node__author {
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: rgb(245 245 244);
  color: rgb(120 113 108);
  font-size: 0.7rem;
}

.thread-node__author--topic {
  background: rgb(254 242 242);
  color: rgb(127 29 29);
}

.thread-node__text {
  margin-top: 0.25rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  font-size: 0.85rem;
  line-height: 1.55;
  color: rgb(87 83 78);
}

.thread-ellipsis {
  margin: 0.25rem 0 0.25rem 0.1rem;
}

.thread-ellipsis summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: rgb(255 253 248);
  border: 1px dashed rgb(214 211 209);
  color: rgb(127 29 29);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.thread-ellipsis summary::-webkit-details-marker {
  display: none;
}

.thread-ellipsis summary::before {
  content: "⋯";
  font-weight: 700;
}

.thread-ellipsis[open] summary::before {
  content: "▾";
}

.thread-ellipsis[open] {
  margin-bottom: 0.5rem;
}

/* 评论详情卡片 */
.current-comment {
  border-color: rgb(254 202 202);
  background: rgb(255 253 248);
}

/* 仅当存在回复上下文时才显示“当前评论”徽标 */
.current-comment.thread-context {
  position: relative;
}

.current-comment.thread-context::before {
  content: "当前评论";
  position: absolute;
  top: -0.55rem;
  right: 1.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  background: rgb(153 27 27);
  color: rgb(255 253 248);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgb(127 29 29 / 0.2);
}

.reply-hint {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: rgb(168 162 158);
}

.reply-hint a {
  color: rgb(127 29 29);
  font-weight: 600;
  text-decoration: none;
}

.reply-hint a:hover {
  text-decoration: underline;
}

/* 子回复列表 */
.reply-section {
  padding: 1.25rem 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid rgb(231 229 228);
  background: rgb(255 253 248);
}

.reply-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgb(231 229 228);
}

.reply-card {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid rgb(231 229 228);
  background: rgb(250 249 247);
  transition: border-color 150ms ease, background 150ms ease;
}

.reply-card:hover {
  border-color: rgb(252 165 165);
  background: rgb(254 242 242);
}

/* ===== SPA 通用辅助 ===== */
.link {
  text-decoration: underline;
  text-decoration-color: rgb(214 211 209);
  text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease;
}
.link:hover {
  text-decoration-color: currentColor;
}

.spinner {
  display: inline-block;
  width: 2.25rem;
  height: 2.25rem;
  margin: 3rem auto;
  border: 3px solid rgb(231 229 228);
  border-top-color: rgb(127 29 29);
  border-radius: 9999px;
  animation: archive-spin 0.8s linear infinite;
}
@keyframes archive-spin {
  to { transform: rotate(360deg); }
}

.state {
  margin: 3rem auto;
  padding: 2rem;
  max-width: 24rem;
  border: 1px solid rgb(231 229 228);
  border-radius: 1.5rem;
  background: rgb(255 253 248);
  color: rgb(87 83 78);
  font-size: 0.9rem;
  text-align: center;
}
.state .emoji {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.6rem;
}

/* 归档首页双栏布局（lg 断点，对应本地 lg:grid-cols-[280px_minmax(0,1fr)]）*/
@media (min-width: 1024px) {
  .archive-two-col {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

/* ===== 管理端 ===== */
/* 只读状态区：未登录展示当前标记/标签，登录后隐藏 */
.admin-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
}
body.admin-on .admin-state {
  display: none;
}
.ma-state-chip {
  border-radius: 9999px;
  padding: 0.2rem 0.55rem;
  line-height: 1.2;
  font-weight: 500;
}
.ma-state-chip.on {
  background: rgb(185 28 28);
  color: #fff;
}
.ma-state-chip.off {
  background: rgb(120 113 108);
  color: #fff;
}
.ma-state-chip.tag {
  border: 1px dashed rgb(217 119 6);
  background: rgb(255 247 237);
  color: rgb(154 52 18);
}
.ma-state-none {
  color: rgb(168 162 158);
}

/* 操作区（登录后 body.admin-on 才显示） */
.admin-ops {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
}
body.admin-on .admin-ops {
  display: flex;
}

/* 固定登录按钮（右上角，未登录可见，登录后隐藏） */
#admin-fab {
  position: fixed;
  right: 1rem;
  top: 1rem; /* 右上角 */
  z-index: 40;
  /* 父级 #admin-root 是 pointer-events: none 的全屏穿透层，这里要显式恢复 */
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: rgb(120 113 108);
  border: 1px solid rgb(231 229 228);
  background: rgb(255 253 248);
  border-radius: 9999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.06);
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
#admin-fab:hover {
  color: rgb(185 28 28);
  border-color: rgb(254 202 202);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
}
#admin-fab svg {
  width: 1rem;
  height: 1rem;
}
/* Tailwind preflight 给所有 svg 设了 display: block，会盖掉 [hidden] 的 UA 规则 */
#admin-fab svg[hidden] {
  display: none;
}
/* FAB 始终显示：未登录=登录入口；登录后=游客/管理员切换入口 */

/* 标记按钮 */
.ma-btn,
.ma-tag {
  border: 1px solid rgb(231 229 228);
  background: rgb(255 255 255);
  color: rgb(120 113 108);
  border-radius: 9999px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.2;
}
.ma-btn:hover,
.ma-tag:hover {
  border-color: rgb(254 202 202);
  color: rgb(185 28 28);
}
.ma-btn.ma-active,
.ma-tag.ma-active {
  background: rgb(185 28 28);
  border-color: rgb(185 28 28);
  color: #fff;
}
.ma-btn[data-val="2"].ma-active {
  background: rgb(120 113 108);
  border-color: rgb(120 113 108);
}

/* 自定义标签输入框 */
.ma-input {
  width: 5.5rem;
  max-width: 7rem;
  border: 1px solid rgb(231 229 228);
  border-radius: 9999px;
  background: rgb(255 255 255);
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  color: rgb(68 64 60);
  outline: none;
  transition: border-color 0.15s;
}
.ma-input:focus {
  border-color: rgb(185 28 28);
}
.ma-input.ma-active {
  border-color: rgb(185 28 28);
  color: rgb(185 28 28);
}

/* 登录面板（居中 modal，点击卡片「标记」锁按钮触发） */
#admin-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
#admin-root #admin-panel[hidden],
#admin-root #admin-backdrop[hidden] {
  display: none;
}
/* 面板打开时的全屏承接层：透明不遮挡页面，只用来承接“点击面板外关闭” */
#admin-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}
#admin-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18rem;
  border: 1px solid rgb(231 229 228);
  border-radius: 1.25rem;
  background: rgb(255 253 248);
  box-shadow: 0 20px 48px rgb(28 25 23 / 0.18);
  padding: 1rem;
  font-size: 0.85rem;
  pointer-events: auto;
}
#admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
#admin-panel-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  color: rgb(168 162 158);
  cursor: pointer;
}
#admin-panel-close:hover {
  color: rgb(68 64 60);
}

/* 标记进度条（归档 Hero 内） */
.mark-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.mark-bar {
  flex: 1;
  height: 0.5rem;
  border-radius: 9999px;
  background: rgb(231 229 228);
  overflow: hidden;
}
.mark-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, rgb(185 28 28), rgb(225 29 72));
  transition: width 0.3s ease;
}
.mark-bar-label {
  font-size: 0.7rem;
  color: rgb(120 113 108);
  white-space: nowrap;
}
