/* study-dezo 公共样式：冷白纸面 + 墨蓝强调色。无外部字体或 CDN。 */
:root {
  --paper: #f6f8fc;
  --surface: #ffffff;
  --ink: #172036;
  --muted: #55627d;
  --line: #d8e0ee;
  --line-strong: #b9c5db;
  --accent: #1f4fd6;
  --accent-deep: #163aa3;
  --accent-soft: #e8effd;
  --grid: rgba(31, 79, 214, 0.07);
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #05603a;
  --ok-soft: #e6f6ee;
  --busy: #8a4b00;
  --busy-soft: #fff4de;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC",
    "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, "Noto Sans Mono CJK SC", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-deep); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { line-height: 1.35; }
code { font-family: var(--mono); font-size: 0.92em; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; min-height: 60vh; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0.5rem; z-index: 100;
  background: var(--ink); color: #fff; padding: 0.5rem 1rem; border-radius: 6px;
}
.skip-link:focus { left: 0.5rem; color: #fff; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 42rem; }

/* ---------- 站点头部 / 页脚 ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; flex-wrap: wrap; padding-top: 0.75rem; padding-bottom: 0.75rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.brand:hover { color: var(--accent); }
.header-search { display: flex; gap: 0.5rem; flex: 1 1 14rem; max-width: 26rem; }
.header-search input { flex: 1 1 auto; min-width: 0; }
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: 0.875rem; }

/* ---------- 表单与按钮 ---------- */
input[type="text"], input[type="search"], input[type="password"], input[type="file"], select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 0.5rem 0.7rem; max-width: 100%;
}
input[type="text"], input[type="search"], input[type="password"], select, textarea { min-height: 2.5rem; }
input[type="file"] { width: 100%; padding: 0.4rem; }
textarea { width: 100%; resize: vertical; }
.field:not(.inline) input[type="text"], .field:not(.inline) input[type="search"], .field:not(.inline) input[type="password"],
.field:not(.inline) select { width: 100%; }
input[readonly] { background: #f0f3f9; color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
button, .button {
  font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.5rem; padding: 0.45rem 1.1rem; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 6px;
}
.button:hover, button:hover { border-color: var(--accent); color: var(--accent-deep); }
.button.primary, .header-search button, .big-search button {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.button.primary:hover, .header-search button:hover, .big-search button:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.button.danger { color: var(--danger); border-color: #e3a49d; }
.button.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.button.small { min-height: 2rem; padding: 0.2rem 0.7rem; font-size: 0.875rem; }
button[disabled], .button[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; }
.link-button:hover { background: none; color: var(--accent-deep); }
.danger-link, .link-button.danger-link { color: var(--danger); }
.inline-form { display: inline; margin: 0; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1rem 0; }

.field { margin: 0 0 1.1rem; min-width: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field.inline { display: flex; flex-direction: column; margin: 0; }
.field.check { display: flex; align-items: center; gap: 0.6rem; }
.field.check label { margin: 0; font-weight: 500; }
.field.check input { width: 1.25rem; height: 1.25rem; }
.hint { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.875rem; }
.field-error { margin: 0.35rem 0 0; color: var(--danger); font-size: 0.9rem; font-weight: 500; }
.error-mark {
  display: inline-block; margin-right: 0.4rem; padding: 0 0.4rem; font-size: 0.75rem; font-weight: 700;
  color: #fff; background: var(--danger); border-radius: 3px;
}
.field-grid { display: grid; grid-template-columns: 1fr; gap: 0 1.25rem; }

/* ---------- 提示 ---------- */
.flashes { margin-bottom: 1rem; }
.flash { margin: 0 0 0.5rem; padding: 0.7rem 1rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.flash-tag { display: inline-block; margin-right: 0.6rem; padding: 0 0.45rem; font-size: 0.75rem; font-weight: 700; border-radius: 3px; color: #fff; background: var(--accent); }
.flash-success { border-color: #9fd8bb; background: var(--ok-soft); }
.flash-success .flash-tag { background: var(--ok); }
.flash-error { border-color: #e9a8a1; background: var(--danger-soft); }
.flash-error .flash-tag { background: var(--danger); }
.notice { margin: 1rem 0; padding: 0.8rem 1.1rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.notice p { margin: 0.3rem 0; }
.notice-error { background: var(--danger-soft); border-color: #e9a8a1; }
.notice-busy { background: var(--busy-soft); border-color: #ecc98a; }
.notice-info { background: var(--accent-soft); border-color: #b9ccf5; }
.warning-list { margin: 0.4rem 0 0.2rem; padding-left: 1.3rem; }
.warning-list li { margin: 0.25rem 0; }

.empty-state { margin: 1.5rem 0; padding: 2rem 1.25rem; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; background: rgba(255,255,255,0.6); }
.empty-title { margin: 0 0 0.3rem; font-size: 1.1rem; font-weight: 600; color: var(--ink); }
.empty-state p { margin: 0.2rem 0; }
.badge { display: inline-block; padding: 0.05rem 0.55rem; font-size: 0.8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--muted); white-space: nowrap; }
.badge-ok { color: var(--ok); border-color: #8fd0ae; background: var(--ok-soft); }
.badge-error { color: var(--danger); border-color: #e3a49d; background: var(--danger-soft); }
.badge-busy { color: var(--busy); border-color: #ecc98a; background: var(--busy-soft); }

.page-title { font-size: 1.6rem; margin: 0.4rem 0 0.8rem; }
.section-title { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; }

/* ---------- 分页 ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.75rem 1rem; margin: 2rem 0 0.5rem; }
.page-link { display: inline-block; padding: 0.4rem 1rem; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; text-decoration: none; }
.page-link.is-disabled { color: #8a95ab; background: transparent; border-style: dashed; }
.page-status { color: var(--muted); font-size: 0.9rem; }

/* ---------- 首页：目录页 ---------- */
.masthead {
  margin: 0 -1.25rem 2rem; padding: 2.5rem 1.25rem 2.25rem;
  background-color: var(--surface);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  border-bottom: 1px solid var(--line);
  border-left: 6px solid var(--accent);
}
.masthead-title { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: 0.04em; }
.masthead-lead { margin: 0.4rem 0 1.4rem; color: var(--muted); font-size: 1.05rem; }
.big-search { display: flex; gap: 0.5rem; max-width: 36rem; }
.big-search input { flex: 1 1 auto; min-width: 0; min-height: 3rem; font-size: 1.05rem; }
.big-search button { min-height: 3rem; padding: 0 1.4rem; }

.index-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.rail-title { font-size: 0.95rem; margin: 0 0 0.5rem; color: var(--muted); font-weight: 600; }
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rail-list a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.8rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; text-decoration: none; color: var(--ink); }
.rail-list a:hover { border-color: var(--accent); color: var(--accent-deep); }
.rail-list a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.rail-list .count { font-size: 0.8rem; opacity: 0.75; }
.index-main { min-width: 0; }
.index-main .section-title { margin-top: 0; }

.contents { list-style: none; margin: 0; padding: 0; }
.contents-row { padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.contents-line { display: flex; align-items: baseline; gap: 0.6rem; }
.contents-title { flex: 0 1 auto; min-width: 0; font-size: 1.15rem; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.contents-title:hover { color: var(--accent); text-decoration: underline; }
.leader { flex: 1 1 1rem; min-width: 1rem; border-bottom: 2px dotted var(--line-strong); transform: translateY(-0.3em); }
.contents-date { flex: none; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.contents-summary { margin: 0.35rem 0 0; color: var(--muted); max-width: 46rem; overflow-wrap: anywhere; }
.contents-meta { margin: 0.3rem 0 0; font-size: 0.85rem; }

.search-head { margin-bottom: 1rem; }
.result-count { color: var(--muted); }

/* ---------- 文章页 ---------- */
.preview-banner { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; margin-bottom: 1rem; padding: 0.6rem 1rem; background: var(--busy-soft); border: 1px solid #ecc98a; border-radius: 6px; }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.article { min-width: 0; }
.article-head { margin-bottom: 1.5rem; padding-left: 1rem; border-left: 4px solid var(--accent); }
.article-category { margin: 0 0 0.3rem; font-size: 0.9rem; }
.article-title { margin: 0; font-size: 1.85rem; line-height: 1.35; overflow-wrap: anywhere; }
.article-dates { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }
.article-foot { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.toc { order: -1; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.75rem; }
.toc-title { display: none; margin: 0 0 0.4rem; font-weight: 700; }
.toc-toggle { width: 100%; justify-content: space-between; border: 0; background: none; padding: 0.3rem 0; font-weight: 600; }
.toc-toggle::after { content: "展开"; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.toc.is-open .toc-toggle::after { content: "收起"; }
.toc-list { list-style: none; margin: 0.3rem 0 0.2rem; padding: 0; }
.js .toc:not(.is-open) .toc-list { display: none; }
.toc-item a { display: block; padding: 0.2rem 0; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; font-size: 0.95rem; }
.toc-item a:hover { color: var(--accent); text-decoration: underline; }
.toc-l2 { padding-left: 0.8rem; }
.toc-l3 { padding-left: 1.6rem; font-size: 0.9rem; }
.toc-l4, .toc-l5, .toc-l6 { padding-left: 2.4rem; }

/* ---------- 正文排版（公众阅读页 + 后台预览共用） ---------- */
.prose { font-size: 1.0625rem; line-height: 1.95; overflow-wrap: break-word; min-width: 0; max-width: 40rem; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { margin: 2em 0 0.7em; scroll-margin-top: 1rem; overflow-wrap: anywhere; }
.prose h1 { font-size: 1.6rem; }
.prose h2 { font-size: 1.4rem; padding-bottom: 0.3em; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 1.2rem; }
.prose h4, .prose h5, .prose h6 { font-size: 1.05rem; }
.prose p { margin: 0 0 1.1em; }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.6em; }
.prose li { margin: 0.25em 0; }
.prose li > p { margin: 0.3em 0; }
.prose blockquote { margin: 1.3em 0; padding: 0.2em 1.1em; color: #34425f; background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 6px 6px 0; }
.prose blockquote p:last-child { margin-bottom: 0.4em; }
.prose hr { border: 0; border-top: 1px solid var(--line-strong); margin: 2em 0; }
.prose img { display: block; margin: 1.2em auto; border-radius: 4px; }
.prose code { background: #edf1f9; padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
.prose pre { margin: 1.3em 0; padding: 0.9rem 1rem; overflow-x: auto; max-width: 100%; background: #f1f4fb; border: 1px solid var(--line); border-radius: 8px; line-height: 1.6; font-size: 0.9rem; tab-size: 4; -webkit-overflow-scrolling: touch; }
.prose pre code { background: none; padding: 0; white-space: pre; overflow-wrap: normal; word-break: normal; }
.table-wrap { margin: 1.3em 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.prose table { border-collapse: collapse; min-width: 100%; width: max-content; font-size: 0.95rem; line-height: 1.6; }
.prose th, .prose td { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--accent-soft); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose th:last-child, .prose td:last-child { border-right: 0; }
.img-missing { display: inline-block; padding: 0.15em 0.6em; color: var(--busy); background: var(--busy-soft); border: 1px dashed #d9b36a; border-radius: 4px; font-size: 0.9em; }

.error-page { padding: 2rem 0 3rem; max-width: 34rem; }
.error-code { margin: 0; font-size: 3rem; font-weight: 700; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- 宽屏 ---------- */
@media (min-width: 860px) {
  .index-layout { grid-template-columns: 13rem minmax(0, 1fr); gap: 2.5rem; }
  .rail-list { display: block; }
  .rail-list li { margin: 0; }
  .rail-list a { display: flex; justify-content: space-between; padding: 0.4rem 0.75rem; border: 0; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; background: transparent; }
  .rail-list a:hover { background: var(--accent-soft); }
  .rail-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-deep); border-left-color: var(--accent); font-weight: 600; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .masthead { margin-left: 0; margin-right: 0; border-radius: 0 8px 8px 0; padding-left: 2rem; }
}
@media (min-width: 1000px) {
  .article-layout { grid-template-columns: minmax(0, 1fr) 15rem; gap: 3rem; }
  .article-title { font-size: 2.15rem; }
  .toc { order: 0; position: sticky; top: 1.25rem; align-self: start; max-height: calc(100vh - 2.5rem); overflow-y: auto; background: transparent; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 0 0 0 1rem; }
  .toc-toggle { display: none; }
  .toc-title { display: block; }
  .js .toc:not(.is-open) .toc-list { display: block; }
}
@media (max-width: 520px) {
  .masthead-title { font-size: 1.6rem; }
  .big-search { flex-direction: column; }
  .big-search button { width: 100%; }
  .contents-line { flex-wrap: wrap; }
  .leader { display: none; }
  .contents-date { flex-basis: 100%; }
  .prose { font-size: 1rem; line-height: 1.9; }
  .page-link { flex: 1 1 40%; text-align: center; }
  .page-status { order: -1; flex-basis: 100%; text-align: center; }
}
@media (prefers-reduced-motion: no-preference) {
  .contents-title, .button, .rail-list a { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
}
@media print {
  .site-header, .site-footer, .toc, .skip-link, .article-foot { display: none; }
  .prose { max-width: none; }
}
