/* 阅读页（文章）与视频单集页：在 home.css 之上加载。
   文章页三种底色：浅色（默认）/ 米白 / 深色，存在本机浏览器（localStorage: agt.theme），挂在 <html data-rt="…">。
   正文 18px、行高 1.9、每行约 37 个汉字。 */

.rd-page { --rd-bg: #FFFFFF; --rd-fg: #0B1B3A; --rd-muted: #4A5B78; --rd-line: #E3E8F2; --rd-card: #F4F7FC; --rd-bar: rgba(255, 255, 255, .9); --rd-link: #0D58E8; }
html[data-rt="sepia"] .rd-page { --rd-bg: #F7F3EA; --rd-fg: #2A2418; --rd-muted: #6B604C; --rd-line: #E6DDCB; --rd-card: #EFE8D9; --rd-bar: rgba(247, 243, 234, .92); --rd-link: #8A4B0F; }
html[data-rt="dark"] .rd-page { --rd-bg: #0A1530; --rd-fg: #E7EEF9; --rd-muted: #A9B8D2; --rd-line: rgba(255, 255, 255, .12); --rd-card: #11224A; --rd-bar: rgba(10, 21, 48, .9); --rd-link: #7FE9F6; }
html[data-rt="dark"] { color-scheme: dark; }

body.rd-page { background: var(--rd-bg); color: var(--rd-fg); transition: background .3s, color .3s; }
.rd-page .tn { background: var(--rd-bar); border-color: var(--rd-line); }
.rd-page .tn-brand, .rd-page .tn-nav a:hover { color: var(--rd-fg); }
.rd-page .tn-nav a { color: var(--rd-muted); }
html[data-rt="dark"] .rd-page .tn-cta { background: #FFF; color: #0A1530; }
.rd-page .ft { border-color: var(--rd-line); color: var(--rd-muted); }
.rd-page .ft a { color: var(--rd-muted); }

/* 阅读进度条（贴在顶栏底边） */
.rd-progress { height: 3px; background: transparent; }
.rd-progress i { display: block; height: 3px; width: 0; background: linear-gradient(90deg, #16D8EE, #0D58E8, #9C5CFF); transform-origin: left; }

/* ---------- 文章页 ---------- */
main.rd { max-width: 1200px; margin: 0 auto; padding: 36px var(--gutter) 56px; display: flex; gap: 48px; align-items: flex-start; }
.rd-side { flex: 0 0 220px; min-width: 0; position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; font-size: 14px; max-height: calc(100vh - 100px); overflow: auto; }
.rd-toc > summary { list-style: none; font-family: var(--mono); font-size: 11px; letter-spacing: .16em; color: var(--rd-muted); cursor: pointer; margin-bottom: 8px; }
.rd-toc > summary::-webkit-details-marker { display: none; }
.rd-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rd-toc a { display: block; padding: 6px 10px; border-left: 2px solid var(--rd-line); color: var(--rd-muted); line-height: 1.5; transition: border-color .2s, color .2s; }
.rd-toc a.lv3 { padding-left: 22px; font-size: 13px; }
.rd-toc a:hover { color: var(--rd-fg); }
.rd-toc a.on { border-color: #0D58E8; color: var(--rd-fg); font-weight: 700; }
.rd-where { padding: 14px; border-radius: 12px; background: var(--rd-card); border: 1px solid var(--rd-line); font-size: 13px; line-height: 1.7; color: var(--rd-muted); }
.rd-where b { color: var(--rd-fg); }
.rd-where a { color: var(--rd-link); }

.rd-art { flex: 1 1 auto; min-width: 0; max-width: 720px; display: flex; flex-direction: column; gap: 20px; }
.rd-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.rd-art > .rd-top .tag { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: #0D58E8; }
html[data-rt="dark"] .rd-art > .rd-top .tag { color: #7FE9F6; }
.rd-themes { display: flex; gap: 6px; }
.rd-themes button { font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rd-line); background: transparent; color: var(--rd-muted); cursor: pointer; transition: background .2s, color .2s; }
.rd-themes button[aria-pressed="true"] { background: #0D58E8; border-color: #0D58E8; color: #FFF; }
.rd-art h1 { font-family: var(--serif); font-size: clamp(28px, 4vw, 42px); line-height: 1.3; font-weight: 900; text-wrap: balance; }
.rd-know { border-radius: 16px; padding: 16px 20px; background: var(--rd-card); border: 1px solid var(--rd-line); display: flex; flex-direction: column; gap: 6px; }
.rd-know b { font-size: 15px; }
.rd-know p, .rd-know ul { margin: 0; font-size: 15px; line-height: 1.8; color: var(--rd-muted); }
.rd-know ul { padding-left: 1.2em; }

/* 正文排版：18px、行高 1.9、每行约 37 字 */
.prose { font-size: 18px; line-height: 1.9; max-width: 37em; overflow-wrap: anywhere; }
.prose > * { margin: 0 0 1.1em; }
.prose a { color: var(--rd-link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose h2, .prose h3, .prose h4 { font-family: var(--serif); line-height: 1.45; margin: 1.6em 0 .6em; scroll-margin-top: 90px; }
.prose h2 { font-size: 28px; } .prose h3 { font-size: 23px; } .prose h4 { font-size: 19px; }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 4px solid #9C5CFF; font-family: var(--serif); font-size: 21px; line-height: 1.7; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .3em 0; }
.prose hr { border: 0; border-top: 1px solid var(--rd-line); margin: 2em 0; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--rd-card); padding: .1em .35em; border-radius: 5px; }
.prose pre.code { background: var(--rd-card); border: 1px solid var(--rd-line); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.6; }
.prose pre.code code { background: none; padding: 0; }
.prose figure { margin: 1.4em 0; }
.prose figure img, .prose figure video { display: block; width: 100%; height: auto; border-radius: 12px; }
.prose figcaption { margin-top: 8px; font-size: 14px; color: var(--rd-muted); text-align: center; }
.prose .embed { position: relative; aspect-ratio: 16 / 9; }
.prose .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 12px; }
.prose .callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--rd-card); border: 1px solid var(--rd-line); }
.prose .callout > div > :last-child { margin-bottom: 0; }
.prose .table-wrap { overflow-x: auto; }
.prose table { border-collapse: collapse; font-size: 15px; line-height: 1.6; min-width: 100%; }
.prose td { border: 1px solid var(--rd-line); padding: 8px 10px; vertical-align: top; }
.prose details { border: 1px solid var(--rd-line); border-radius: 12px; padding: 10px 14px; }
.prose details > summary { cursor: pointer; font-weight: 700; }
.prose .bookmark a, .prose .file a { word-break: break-all; }

/* 名词卡 */
.term { border-bottom: 2px dotted #0D58E8; cursor: help; border-radius: 2px; }
html[data-rt="dark"] .term { border-color: #7FE9F6; }
.term:focus-visible { outline: 3px solid rgba(13, 88, 232, .45); outline-offset: 2px; }
.gl-pop {
  position: absolute; z-index: 40; width: min(320px, calc(100vw - 32px));
  border-radius: 14px; padding: 14px 16px; background: #0B1B3A; color: #FFF;
  font-size: 14px; line-height: 1.75; box-shadow: 0 18px 40px -20px rgba(8, 40, 95, .8);
  animation: pop .18s ease both;
}
.gl-pop b { display: block; color: #16D8EE; margin-bottom: 2px; }
.gl-pop small { display: block; margin-top: 6px; font-size: 12px; color: #9FB0CC; }
@keyframes pop { from { transform: translateY(4px); } }

/* 上一篇 / 下一篇（文章和视频共用） */
.pn-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.pn { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--rd-line, #E3E8F2); background: var(--rd-card, #F4F7FC); color: var(--rd-fg, #0B1B3A); min-width: 0; transition: transform .25s ease, box-shadow .25s ease; }
.pn:hover { color: var(--rd-fg, #0B1B3A); transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(8, 40, 95, .45); }
.pn small { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--rd-muted, #4A5B78); }
.pn b { font-size: 16px; line-height: 1.5; }
.pn.next { text-align: right; grid-column: 2; }
.pn.next.solo { grid-column: 2; }
.pn.hot { background: linear-gradient(135deg, #0D58E8, #9C5CFF); border-color: transparent; color: #FFF; }
.pn.hot small { color: rgba(255, 255, 255, .85); }
.pn.hot:hover { color: #FFF; }
.rd-art .back, .post .back { color: var(--rd-link, #0D58E8); }

/* ---------- 视频单集页（标记不变：article.post > .tag / h1 / .player / 正文 / .back） ---------- */
main.ep-page { max-width: 1000px; margin: 0 auto; padding: 32px var(--gutter) 56px; }
.ep-page .post { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.ep-page .post > h1 { font-size: clamp(26px, 3.6vw, 38px); line-height: 1.3; font-weight: 900; text-wrap: balance; }
.ep-page .player { border-radius: 16px; overflow: hidden; background: #000; box-shadow: 0 30px 60px -40px rgba(8, 40, 95, .9); }
.ep-page .player video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.ep-page .post > :not(.player):not(h1):not(.tag):not(.pn-nav):not(.back):not(.ep-seen) { font-size: 17px; line-height: 1.9; max-width: 40em; margin: 0; }
.ep-page .post figure img, .ep-page .post figure video { width: 100%; height: auto; border-radius: 12px; display: block; }
.ep-page .post blockquote { border-left: 4px solid #9C5CFF; padding-left: 18px; }
.ep-seen { align-self: flex-start; font-size: 13px; font-weight: 700; color: #0B7C8C; background: #E3FAFD; padding: 3px 10px; border-radius: 999px; }

/* 评论区（Twikoo，原样保留，只换外框） */
.comments { max-width: 1000px; margin: 0 auto; padding: 8px var(--gutter) 48px; }
.rd-page .comments { max-width: 1200px; }
.comments .sec-head h2 { font-size: 22px; font-weight: 900; margin-bottom: 12px; }

@media (max-width: 960px) {
  main.rd { flex-direction: column; gap: 20px; padding-top: 20px; }
  .rd-side { position: static; flex: none; width: 100%; max-height: none; order: 0; }
  .rd-art { order: 1; max-width: none; }
  .rd-where { display: none; }
  .rd-toc { border: 1px solid var(--rd-line); border-radius: 12px; padding: 10px 12px; background: var(--rd-card); }
  .rd-toc > summary { margin-bottom: 0; }
  .rd-toc[open] > summary { margin-bottom: 8px; }
}
@media (max-width: 560px) {
  .prose { font-size: 17px; line-height: 1.85; }
  .prose h2 { font-size: 24px; } .prose h3 { font-size: 20px; }
  .prose blockquote { font-size: 19px; }
  .pn-nav { grid-template-columns: minmax(0, 1fr); }
  .pn.next, .pn.next.solo { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  body.rd-page, .rd-toc a, .rd-themes button, .pn { transition: none !important; }
  .pn:hover { transform: none !important; }
  .gl-pop { animation: none !important; }
}

/* ==== 深色外观（跟随系统 + 文章页手动「深色」；make_dark_home.py 生成，别手改） ==== */
@media (prefers-color-scheme: dark) {
  html:not([data-rt]) .rd-page { --rd-bg: #0A1530; --rd-fg: #E7EEF9; --rd-muted: #A9B8D2; --rd-line: rgba(255, 255, 255, .12); --rd-card: #11224A; --rd-bar: rgba(10, 21, 48, .9); --rd-link: #7FE9F6; }
  html:not([data-rt]) .rd-page .tn-cta, html:not([data-rt]) .rd-page .tn-cta:hover { background: #FFF; color: #0A1530; }
  html:not([data-rt]) .term { border-color: #7FE9F6; }
}
html[data-rt="dark"] .rd-page { --rd-bg: #0A1530; --rd-fg: #E7EEF9; --rd-muted: #A9B8D2; --rd-line: rgba(255, 255, 255, .12); --rd-card: #11224A; --rd-bar: rgba(10, 21, 48, .9); --rd-link: #7FE9F6; }
html[data-rt="dark"] .rd-page .tn-cta, html[data-rt="dark"] .rd-page .tn-cta:hover { background: #FFF; color: #0A1530; }
html[data-rt="dark"] .term { border-color: #7FE9F6; }
/* ==== 深色外观结束 ==== */
