/* ===========================================================
   V5 · 结构层
   方案 B：结构与节奏换成「阅读工作台」，配色与宋体标题保留。
   本文件在 style.css 之后加载，只覆盖布局 / 层级 / 间距，
   不重新定义任何颜色变量 —— 五套主题与明暗照旧生效。
   =========================================================== */

/* ---------- 0. 基础 ---------- */
/* 只在语义上需要、视觉上不该出现的文字（首页 h1 等） */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 主色只用于「当前状态」：竖条、下划线、选中项 */
:root {
  --fast: .12s ease;
  --base: .18s ease;
}

/* ---------- 1. 顶栏：下划线导航 ---------- */
.topbar-in {
  padding-top: 0;
  padding-bottom: 0;
  min-height: 62px;
  align-items: stretch;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  padding-right: 10px;
}

.nav {
  margin-left: 0;
  gap: 0;
  align-items: stretch;
}
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 0;
  background: none;
  font-size: .92rem;
  color: var(--muted);
  transition: color var(--base);
}
.nav a::after {
  content: "";
  position: absolute;
  left: 13px; right: 13px; bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background var(--base);
}
.nav a:hover { background: none; color: var(--ink); }
.nav a.on {
  background: none;
  color: var(--ink);
  font-weight: 600;
}
.nav a.on::after { background: var(--primary); }

/* ---------- 2. 外观气泡 ---------- */
.appearance {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 10px;
}

.ico-btn {
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: background var(--fast), color var(--fast);
}
.ico-btn:hover { background: var(--soft); color: var(--ink); }
.ico-btn[aria-expanded="true"] { background: var(--soft); color: var(--primary-dp); }
.ico-btn svg { width: 16px; height: 16px; }

.appear-pop {
  position: absolute;
  top: calc(100% - 6px);
  right: 0;
  z-index: 60;
  width: 264px;
  padding: 16px 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 46px -22px var(--shadow-2), 0 2px 6px var(--shadow);
  animation: pop-in .16s ease both;
}
.appear-pop[hidden] { display: none; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.ap-t {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}
.ap-t + .ap-modes { margin-bottom: 16px; }

.ap-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-2);
}
.ap-modes button {
  font: inherit;
  font-size: .8rem;
  padding: 7px 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.ap-modes button:hover { color: var(--ink); }
.ap-modes button.on {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow);
}

/* 气泡里的配色圆点：比原来大，触控区 26px */
.ap-dots.theme-picker {
  display: flex;
  gap: 9px;
  padding-left: 0;
  margin-left: -2px;
  border-left: 0;
}
.ap-dots.theme-picker label {
  width: 26px; height: 26px;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--rule);
}
.ap-dots.theme-picker label:hover { transform: none; box-shadow: 0 0 0 1px var(--ink); }
.ap-dots.theme-picker input:checked + label {
  box-shadow: 0 0 0 1px var(--dot), 0 0 0 3.5px color-mix(in srgb, var(--dot) 26%, transparent);
}

/* ---------- 3. 首页状态行 ---------- */
/* 替代原来的卷首大标题：一行给出「有多少、多久没更新」 */
.statusbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--rule);
  font-size: .82rem;
  color: var(--muted);
}
.statusbar b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.statusbar .sep {
  width: 1px;
  height: 11px;
  background: var(--rule);
  flex: none;
}
.statusbar .sb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.statusbar .sb-right a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .82rem;
  transition: color var(--fast);
}
.statusbar .sb-right a:hover { color: var(--primary-dp); }
.statusbar .sb-right .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* ---------- 4. 首页栅格 ---------- */
.home-grid {
  gap: 34px;
  padding-top: 26px;
  padding-bottom: 46px;
}

.toolbar { margin-bottom: 4px; }
.tags { margin: 16px 0 8px; }

/* 工具条不再做成一张卡片：按 P2「用线分，不用框套」，
   搜索框自己就是一个输入框，没必要再套一层白底 */
.toolbar {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 20px 0 4px;
}
.search input { background: var(--surface); }
.sortbar { box-shadow: none; }

/* ---------- 5. 列表行 ---------- */
/* 66px 日期锚点 + 主内容 + 100px 缩略图；没有封面就两列 */
.row {
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 0 22px;
  padding: 20px 4px 20px 0;
  transition: background-color var(--base);
}
.row:first-child { border-top: 0; }
.row:hover {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--primary) 5%, transparent),
    transparent 72%);
}
.row::before { left: -14px; top: 18px; bottom: 18px; }

@media (min-width: 620px) {
  .row.has-thumb {
    grid-template-columns: 66px minmax(0, 1fr) 100px;
    gap: 0 22px;
  }
}

.row-date {
  padding-top: 2px;
  gap: 3px;
  line-height: 1.2;
}
/* 「11.01」在上、「周六」在下：时间线里更好扫 */
.row-date b {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
  margin-top: 0;
}
.row-date span {
  font-size: .68rem;
  letter-spacing: .04em;
  opacity: .7;
}
.row:hover .row-date b { color: var(--primary); }

.row-title {
  font-size: 1.2rem;
  line-height: 1.46;
  margin: 0 0 5px;
}

.row-desc {
  margin: 0 0 8px;
  font-size: .875rem;
  line-height: 1.62;
  -webkit-line-clamp: 1;
}

.row-meta {
  gap: 7px;
  font-size: .74rem;
}
.row-meta .pill {
  font-size: .68rem;
  padding: 1px 7px;
  border-radius: 4px;
}

.row-thumb {
  width: 100px;
  height: 68px;
  border-radius: 8px;
}

/* 列表行的悬停竖条与背景叠加时不要发虚 */
@media (hover: none) {
  .row:hover { background: none; }
}

/* ---------- 6. 特稿 ---------- */
.feature { border-radius: 12px; }
.feature-cover { min-height: 200px; }

/* ---------- 7. 侧栏 ---------- */
/* 去掉每个块的分割线，靠留白分组的侧栏更安静 */
.side-card {
  padding-bottom: 0;
  margin-bottom: 30px;
  border-bottom: 0;
}
.side-title {
  letter-spacing: .16em;
  margin-bottom: 13px;
}
.side-card.about .side-title { margin-bottom: 10px; }

.rank li { margin-bottom: 12px; }
.rank a { font-size: .85rem; }

/* 订阅从「胶囊按钮」改成一行文字链接 */
.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: .86rem;
  color: var(--ink);
}
.rss-link:hover { color: var(--primary-dp); transform: none; border: 0; }
.side-hint { margin-top: 9px; font-size: .76rem; }

/* ---------- 8. 文章页：移动端目录抽屉 ---------- */
.toc-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 55;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .84rem;
  box-shadow: 0 8px 24px -14px var(--shadow-2);
  cursor: pointer;
}
.toc-fab svg { width: 15px; height: 15px; }

.toc-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 56;
  background: hsl(0 0% 10% / .38);
  animation: lb-in .18s ease both;
}

@media (max-width: 1079px) {
  .toc-fab { display: inline-flex; }

  /* 目录从右栏变成底部抽屉，随时可呼出 */
  .toc-rail {
    display: block;            /* 桌面端是 none，这里必须显式打开 */
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 57;
    max-height: 72vh;
    overflow: auto;
    padding: 20px 22px 30px;
    border-top: 1px solid var(--rule);
    border-radius: 18px 18px 0 0;
    background: var(--surface);
    box-shadow: 0 -14px 40px -22px var(--shadow-2);
    transform: translateY(110%);
    transition: transform .24s cubic-bezier(.22,.61,.36,1);
  }
  body.toc-open .toc-rail { transform: none; }
  body.toc-open { overflow: hidden; }
  .toc-mask { display: none; }
  body.toc-open .toc-mask { display: block; }
}

/* 抽屉里的目录条目要够大，手指点得准 */
@media (max-width: 1079px) {
  /* 抽屉里不要那条竖向边线，改成每一条自己的左侧标记 */
  .toc {
    position: static;
    border-left: 0;
    padding-left: 0;
  }
  .toc::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--rule);
    margin: -6px auto 16px;
  }
  .toc-title {
    margin-bottom: 10px;
    font-size: .72rem;
    letter-spacing: .16em;
  }
  .toc a {
    display: block;
    padding: 11px 0 11px 13px;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
    font-size: .92rem;
    color: var(--muted);
  }
  .toc a.on {
    border-left-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
    color: var(--primary-dp);
  }
  .toc a.lv3 { padding-left: 25px; }
}

/* ---------- 9. 归档页 ---------- */
.archive-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--rule);
  font-size: .82rem;
  color: var(--muted);
}
.archive-head b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.archive-head .sep { width: 1px; height: 11px; background: var(--rule); }

.archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 28px 0 60px;
  align-items: start;
}
@media (min-width: 900px) {
  .archive-layout {
    grid-template-columns: 148px minmax(0, 820px);
    gap: 56px;
    /* 归档是「索引」，比正文窄一点更好扫；整块居中，右边才不会空一大条 */
    max-width: 1024px;
    margin: 0 auto;
  }
}

.year-nav {
  display: none;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 88px;
}
@media (min-width: 900px) {
  .year-nav { display: flex; }
}
.year-nav a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 0 6px 11px;
  border-left: 2px solid transparent;
  font-size: .84rem;
  color: var(--muted);
  transition: color var(--fast), border-color var(--fast);
}
.year-nav a:hover { color: var(--ink); }
.year-nav a.on {
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--primary);
}
.year-nav a .n {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .7rem;
  opacity: .7;
}

/* 年份分隔 */
.year-group + .year-group { margin-top: 8px; }
.year-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 0 2px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .72rem;
  letter-spacing: .14em;
  color: var(--muted);
}
.year-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* 归档行：只有日期、标题、时长 */
.arow {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 54px;
  gap: 0 22px;
  align-items: baseline;
  padding: 13px 4px 13px 0;
  border-bottom: 1px solid var(--rule);
  color: inherit;
  transition: background-color var(--fast);
}
.arow:hover {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--primary) 5%, transparent),
    transparent 72%);
}
.arow .d {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.arow .t {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  transition: color var(--fast);
}
.arow:hover .t { color: var(--primary-dp); }
.arow .m {
  text-align: right;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .7rem;
  color: var(--muted);
  opacity: .8;
}

/* ---------- 10. 后台：导航吸顶 ---------- */
.sidenav {
  position: sticky;
  top: 62px;
  align-self: start;
  max-height: calc(100vh - 62px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sidenav { position: static; max-height: none; }
}

/* ---------- 11. 响应式 ---------- */
@media (max-width: 900px) {
  .nav a { padding: 0 10px; }
  .nav a::after { left: 10px; right: 10px; }
}

@media (max-width: 720px) {
  .topbar-in { gap: 0; }
  .nav { gap: 0; }
  .nav a { padding: 0 9px; font-size: .86rem; }
  .nav a::after { left: 9px; right: 9px; }

  .statusbar { padding: 18px 0 14px; font-size: .76rem; }

  .row { grid-template-columns: 52px minmax(0, 1fr); gap: 0 14px; padding: 16px 2px 16px 0; }
  .row-thumb { width: 84px; height: 58px; }
  .row-title { font-size: 1.06rem; }
  .row-desc { font-size: .84rem; }

  .home-grid { gap: 26px; padding-top: 18px; }

  .toolbar { padding: 0; gap: 10px; }

  /* 手机上排序占一整行太费地方，和搜索并排 */
  .toolbar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }
  .toolbar .search { flex: 1 1 auto; min-width: 0; }
  .toolbar-right { flex: 0 0 auto; justify-content: flex-end; }
  .sortbar button { padding: 6px 11px; font-size: .8rem; }

  /* 标签超过一屏时横向滑动，不要折三行把首屏挤没 */
  .tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-right: -18px;
    padding-right: 18px;
  }
  .tags::-webkit-scrollbar { display: none; }
  .tag-btn { flex: 0 0 auto; }

  .feature-cover { min-height: 0; aspect-ratio: 16 / 9; }

  .appear-pop {
    width: min(264px, calc(100vw - 32px));
    right: -6px;
  }
}

@media (max-width: 400px) {
  .row { grid-template-columns: 46px minmax(0, 1fr); gap: 0 11px; }
  .row-date b { font-size: .72rem; }
}

/* 520 以下：旧结构有 6 个导航子元素才需要换行，
   现在只剩 4 个链接，一行放得下，就别把顶栏撑成两行 */
@media (max-width: 520px) {
  .topbar-in { flex-wrap: nowrap; padding: 0 16px; }
  .brand { margin-right: 0; }
  .nav {
    order: 0;
    width: auto;
    margin: 0 0 0 4px;
    padding-top: 0;
    border-top: 0;
    justify-content: flex-start;
  }
  .nav a { padding: 0 9px; }
  .nav a::after { left: 9px; right: 9px; }
}

@media (max-width: 380px) {
  .brand { font-size: 1.02rem; }
  .brand .mark { width: 24px; height: 24px; }
  .nav a { padding: 0 7px; font-size: .82rem; }
  .nav a::after { left: 7px; right: 7px; }
  .ico-btn { width: 30px; height: 30px; }
}

/* 620–720 之间保留三列，缩略图收窄 */
@media (min-width: 620px) and (max-width: 720px) {
  .row.has-thumb {
    grid-template-columns: 52px minmax(0, 1fr) 84px;
    gap: 0 14px;
  }
}

/* ---------- 12. 打印 ---------- */
@media print {
  .appearance, .toc-fab { display: none !important; }
}

/* ---------- 13. 页脚 ----------
   左边版权 + 备案 + 备注，右边后台维护的链接；
   窄屏自动竖排。链接内容由 app.js 的 renderFooter() 注入。 */
.site-footer .wrap.footer-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 28px;
  flex-wrap: wrap;
}

.footer-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.footer-left .icp.on::before {
  content: "·";
  margin: 0 7px;
  opacity: .45;
}

.footer-note { color: var(--muted); }
.footer-note::before {
  content: "·";
  margin: 0 7px;
  opacity: .45;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.footer-links a {
  font-size: .82rem;
  color: var(--muted);
  transition: color var(--fast);
}
.footer-links a:hover { color: var(--primary-dp); }

@media (max-width: 620px) {
  .site-footer .wrap.footer-in {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .footer-links { gap: 16px; }
}

/* 页脚链接要给「回到顶部」圆钮让位，否则滚到底会被压住 */
.site-footer .footer-links { padding-right: 58px; }
@media (max-width: 720px) {
  .site-footer { padding-bottom: 26px; }
  .site-footer .footer-links { padding-right: 0; }
}

/* ===========================================================
   14. 主题底纹
   原来五套主题只改了色相（--h），底色一律 hsl(h 30% 97%)，
   看起来几乎一样。这里让每套主题有自己的底色渐变、光斑位置与强度，
   切换时背景能明显区分，同时保持很淡、不抢正文。
   注意：浅色按 html[data-theme] 生效（JS 会写这个属性），
   深色统一用 html[data-mode="dark"] 覆盖，且写在后面 —— 两者特异性相同。
   =========================================================== */

body {
  --paper-1: hsl(198 40% 96.8%);
  --paper-2: hsl(200 28% 93.5%);
  --glow-a: hsl(196 60% 90% / .80);
  --glow-b: hsl(212 50% 92% / .45);
  --gp-1: 50% -12%;
  --gp-2: 94% 8%;

  background:
    radial-gradient(900px 440px at var(--gp-1), var(--glow-a), transparent 70%),
    radial-gradient(760px 400px at var(--gp-2), var(--glow-b), transparent 72%),
    linear-gradient(180deg, var(--paper-1), var(--paper-2));
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* 薄荷汽水：左上冷光 + 右下青雾 */
html[data-theme="mint"] body {
  --paper-1: hsl(158 45% 96.9%);
  --paper-2: hsl(154 32% 92.8%);
  --glow-a: hsl(156 55% 88% / .85);
  --glow-b: hsl(176 42% 90% / .50);
  --gp-1: 12% -8%;
  --gp-2: 92% 10%;
}

/* 蜜桃乌龙：右上暖光 + 左下蜜色，像午后纸面 */
html[data-theme="peach"] body {
  --paper-1: hsl(30 65% 97.4%);
  --paper-2: hsl(24 45% 93.6%);
  --glow-a: hsl(28 78% 90% / .90);
  --glow-b: hsl(14 58% 92% / .45);
  --gp-1: 70% -10%;
  --gp-2: 10% 12%;
}

/* 莓果气泡：右上藕紫 + 底部淡粉 */
html[data-theme="berry"] body {
  --paper-1: hsl(312 45% 97.3%);
  --paper-2: hsl(306 32% 94.2%);
  --glow-a: hsl(316 60% 91% / .85);
  --glow-b: hsl(340 55% 93% / .45);
  --gp-1: 88% -6%;
  --gp-2: 16% 14%;
}

/* 青柠气泡：顶部黄绿光 + 右侧青雾 */
html[data-theme="lime"] body {
  --paper-1: hsl(78 50% 96.8%);
  --paper-2: hsl(74 38% 93.2%);
  --glow-a: hsl(80 62% 88% / .85);
  --glow-b: hsl(96 45% 91% / .45);
  --gp-1: 30% -10%;
  --gp-2: 86% 6%;
}

/* 深色：底色压深，光斑跟着主题色相走（--h 由主题继承） */
html[data-mode="dark"] body {
  --paper-1: hsl(var(--h) 20% 9%);
  --paper-2: hsl(var(--h) 16% 6.2%);
  --glow-a: hsl(var(--h) 45% 24% / .45);
  --glow-b: hsl(var(--h) 40% 20% / .30);
  background:
    radial-gradient(900px 440px at var(--gp-1), var(--glow-a), transparent 70%),
    radial-gradient(760px 400px at var(--gp-2), var(--glow-b), transparent 72%),
    linear-gradient(180deg, var(--paper-1), var(--paper-2));
}

/* 顶栏跟着底色走，不要在白底上糊一块灰 */
.topbar {
  background: color-mix(in srgb, var(--paper-1) 78%, transparent);
}
