/* Paper surface: documentation, articles, legal. Reading-first. */

.docs-hero { padding-block: var(--space-8) var(--space-6); }
.docs-hero h1 { margin-bottom: var(--space-3); }
.docs-hero .lede { max-width: 76ch; }

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  grid-template-areas: "tree article toc";
  gap: 32px;
  align-items: start;
  max-width: var(--container-docs);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-8);
}
.docs-layout > .article { grid-area: article; min-width: 0; }
.docs-layout > .docs-tree { grid-area: tree; }
.docs-layout > .toc { grid-area: toc; }
.docs-layout.no-toc { grid-template-columns: 220px minmax(0, 1fr); grid-template-areas: "tree article"; }
.docs-layout.no-tree { grid-template-columns: minmax(0, 1fr) 200px; grid-template-areas: "article toc"; }

.docs-tree, .toc {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 6px;
  font-size: var(--text-sm);
}
.docs-tree .tree-heading, .toc .toc-heading {
  margin: 0 0 var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.docs-tree ul, .toc ul { list-style: none; padding: 0; margin: 0; }
.docs-tree li, .toc li { margin: 0 0 2px; }
.docs-tree a, .toc a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.45;
}
.docs-tree a:hover, .toc a:hover { background: var(--bg-subtle); color: var(--text-strong); }
.docs-tree a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.toc a { padding: 5px 8px; font-size: var(--text-xs); }
.toc .toc-sub { padding-left: 12px; }

.article-head { margin-bottom: var(--space-6); }
.article-title {
  margin: 0 0 var(--space-3);
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
/* H1 写成「主题:覆盖范围」时副标题独占一行(tools/techdoc.py 的 h1_markup),
   不让自动断行拆在主题中间 */
.art-title .ttl-sub, .article-title .ttl-sub { display: block; }
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--text-faint);
  font-size: var(--text-sm);
}
.article-lede {
  margin: var(--space-5) 0 0;
  padding-left: var(--space-4);
  border-left: 3px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.65;
}

.article-body { max-width: var(--container-prose); font-size: var(--text-base); line-height: 1.8; }
.article-body > :first-child { margin-top: 0; }
.article-body h2 {
  margin: 2.2em 0 0.6em;
  font-size: var(--text-3xl);
  line-height: 1.3;
  scroll-margin-top: 90px;
}
.article-body h3 {
  margin: 1.8em 0 0.5em;
  font-size: var(--text-2xl);
  line-height: 1.35;
  scroll-margin-top: 90px;
}
.article-body p { margin: 0 0 1.1em; }
.article-body ul, .article-body ol { margin: 0 0 1.1em; }
.article-body a { text-decoration: underline; text-underline-offset: 2px; }
.article-body blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--brand);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.article-body figure { margin: var(--space-6) 0; }
.article-body figure img {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fff;
}
.article-body figcaption {
  margin-top: var(--space-2);
  color: var(--text-faint);
  font-size: var(--text-xs);
  text-align: center;
}
.article-body table { margin: var(--space-4) 0; }
.article-body .table-wrap { margin: var(--space-4) 0; }
.article-body hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-6) 0; }

.prevnext {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.prevnext a {
  display: block;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-body);
  text-decoration: none;
}
.prevnext a:hover { border-color: var(--brand); }
.prevnext .label { display: block; margin-bottom: 4px; color: var(--text-faint); font-size: var(--text-xs); }
.prevnext .next { text-align: right; }
@media (max-width: 600px) { .prevnext { grid-template-columns: 1fr; } .prevnext .next { text-align: left; } }

/* index pages */
.doc-index { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-6); }
.doc-index .card h2 { font-size: 1.2rem; }
.doc-index .card p { margin-bottom: 0; color: var(--text-muted); font-size: var(--text-sm); }
@media (max-width: 700px) { .doc-index { grid-template-columns: 1fr; } }

.chapter { margin-top: var(--space-7); }
.chapter h2 { font-size: 1.2rem; margin-bottom: var(--space-2); }
.chapter .chapter-note { color: var(--text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-4); }
.article-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border-subtle); }
.article-list li { margin: 0; border-bottom: 1px solid var(--border-subtle); }
.article-list a {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: baseline;
  padding: 14px 4px;
  color: var(--text-body);
  text-decoration: none;
}
.article-list a:hover { color: var(--brand); }
.article-list .num { color: var(--text-faint); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.article-list .title { font-weight: 600; }
.article-list .meta { color: var(--text-faint); font-size: var(--text-xs); white-space: nowrap; }
@media (max-width: 600px) {
  .article-list a { grid-template-columns: 36px minmax(0, 1fr); }
  .article-list .meta { display: none; }
}

/* responsive docs layout */
.docs-mobile-nav { display: none; }

/* ── legacy generated markup ────────────────────────────────
   techdoc.py / panvox_articles.py still emit main.doc + docgrid.
   Restyle those classes here so generated pages share the new
   reading layout without a template rewrite. */
main.doc {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  column-gap: 32px;
  max-width: var(--container-docs);
  margin: 0 auto;
  padding: var(--space-7) var(--gutter) var(--space-8);
}
main.doc > * { grid-column: 1 / -1; }
main.doc > .breadcrumb,
main.doc > .art-title,
main.doc > .art-meta,
main.doc > .lede { grid-column: 2; }
main.doc > .breadcrumb { margin-bottom: var(--space-4); }
main.doc > .art-title { margin: 0 0 var(--space-3); font-size: clamp(1.9rem, 3.6vw, 2.6rem); line-height: 1.18; letter-spacing: -0.02em; text-wrap: balance; }
main.doc > .art-meta,
main.doc > .art-meta a { color: var(--text-faint); font-size: var(--text-sm); }
main.doc > .art-meta .dot { margin: 0 8px; color: var(--border-control); }
main.doc > .lede {
  margin-top: var(--space-5);
  margin-bottom: var(--space-6);
  padding-left: var(--space-4);
  border-left: 3px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.65;
}
main.doc > .lede p { margin: 0; }
main.doc > .tagline {
  max-width: 76ch;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.65;
}

.docgrid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  gap: 32px;
  align-items: start;
}
.docgrid > .side {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: var(--text-sm);
}
.docgrid > .sideh { margin: 0 0 var(--space-3); }
.sideh {
  color: var(--text-faint);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tree { list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.tree li { margin: 0 0 2px; }
.tree a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-decoration: none;
}
.tree a:hover { background: var(--bg-subtle); color: var(--text-strong); }
.tree li.cur > a { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.tree.dim a { color: var(--text-faint); }

.doc-content {
  min-width: 0;
  max-width: var(--container-prose);
  font-size: var(--text-base);
  line-height: 1.8;
}
.doc-content > :first-child { margin-top: 0; }
.doc-content h2 {
  margin: 2.2em 0 0.6em;
  font-size: var(--text-3xl);
  line-height: 1.3;
  scroll-margin-top: 90px;
}
.doc-content h3 {
  margin: 1.8em 0 0.5em;
  font-size: var(--text-2xl);
  line-height: 1.35;
  scroll-margin-top: 90px;
}
.doc-content p { margin: 0 0 1.1em; }
.doc-content ul, .doc-content ol { margin: 0 0 1.1em; }
.doc-content a { text-decoration: underline; text-underline-offset: 2px; }
.doc-content blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--brand);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.doc-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: var(--space-5) auto;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fff;
}
.doc-content pre { margin: var(--space-4) 0; }
.doc-content table { margin: var(--space-4) 0; }
.doc-content hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-6) 0; }
.doc-content .faq-list { margin: var(--space-5) 0 var(--space-6); border-top: 1px solid var(--border-subtle); }
.doc-content .faq-list details { border-bottom: 1px solid var(--border-subtle); padding: var(--space-4) 0; }
.doc-content .faq-list summary { cursor: pointer; color: var(--text-strong); font-weight: 600; }
.doc-content .faq-list p { margin: var(--space-3) 0 0; color: var(--text-muted); }

.toc-side { position: sticky; top: 84px; }
.toc-side ul { list-style: none; padding: 0; margin: 0; }
.toc-side li { margin: 0 0 2px; }
.toc-side a {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
  text-decoration: none;
}
.toc-side a:hover { background: var(--bg-subtle); color: var(--text-strong); }

.taglist { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-6) 0 var(--space-4); }
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--border-subtle); }
.prevnext .pn {
  display: block;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-body);
  text-decoration: none;
}
.prevnext .pn:hover { border-color: var(--brand); }
.prevnext .pn .small { display: block; margin-bottom: 4px; color: var(--text-faint); font-size: var(--text-xs); }
.prevnext .pn.empty { border: 0; }

/* legacy index / column lists */
.chgroup { margin-top: var(--space-7); }
.chgroup h2 { font-size: 1.2rem; margin-bottom: var(--space-2); }
.artlist { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border-subtle); }
.artlist li { margin: 0; padding: 14px 4px; border-bottom: 1px solid var(--border-subtle); }
.artlist a { display: block; color: var(--text-body); font-weight: 600; text-decoration: none; }
.artlist a:hover { color: var(--brand); }
.artlist .meta { display: block; margin-top: 4px; color: var(--text-muted); font-size: var(--text-sm); }
.artlist .small { display: block; margin-top: 2px; }

.startpath { margin: var(--space-6) 0 0; }
.startpath h2 { font-size: 1.2rem; }
.startpath ol { list-style: none; padding: 0; margin: var(--space-4) 0 0; }
.startpath li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 160px;
  gap: 4px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border-subtle);
}
.startpath li:last-child { border-bottom: 1px solid var(--border-subtle); }
.startpath .num { grid-row: 1 / 3; color: var(--text-faint); font-size: var(--text-xs); }
.startpath a { grid-column: 2; font-weight: 600; }
.startpath .why { grid-column: 2; color: var(--text-muted); font-size: var(--text-sm); }
.startpath .col { grid-column: 3; grid-row: 1 / 3; align-self: center; color: var(--text-faint); font-size: var(--text-xs); text-align: right; }

.roadmap { margin: var(--space-6) 0 0; }
.roadmap ol { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); }
.roadmap li { border-top: 1px solid var(--border-subtle); padding-top: 10px; }
.roadmap a { display: block; color: inherit; text-decoration: none; }
.roadmap .step { display: block; color: var(--text-faint); font-size: var(--text-xs); }
.roadmap .lb { display: block; margin: 3px 0; font-weight: 650; }
.roadmap .why { display: block; color: var(--text-muted); font-size: var(--text-sm); }

.colcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
.colcard { margin: 0; }
.colcard a { color: inherit; text-decoration: none; }
.colcard h2 { margin: 0 0 4px; font-size: 1.16rem; color: var(--brand); }
.colcard .colen { color: var(--text-faint); font-size: var(--text-sm); }
.colcard.soon { opacity: 0.65; }

@media (max-width: 1100px) {
  main.doc { display: block; }
  .docgrid { grid-template-columns: 1fr; }
  .docgrid > .side { display: none; }
  .doc-content { max-width: none; }
  .roadmap ol { grid-template-columns: 1fr 1fr; }
  .startpath li { grid-template-columns: 26px minmax(0, 1fr); }
  .startpath .col { display: none; }
}
@media (max-width: 700px) {
  .doc-index, .colcards { grid-template-columns: 1fr; }
  .roadmap ol { grid-template-columns: 1fr; }
  .prevnext { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .docs-layout, .docs-layout.no-toc, .docs-layout.no-tree {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "article";
  }
  .docs-layout > .docs-tree, .docs-layout > .toc { display: none; }
  .docs-mobile-nav { display: block; margin: var(--space-5) 0; }
  .docs-mobile-nav details { border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); }
  .docs-mobile-nav summary { padding: 12px 16px; cursor: pointer; color: var(--text-strong); font-weight: 600; }
  .docs-mobile-nav ul { list-style: none; margin: 0; padding: 0 8px 10px; }
  .docs-mobile-nav a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text-muted); font-size: var(--text-sm); text-decoration: none; }
  .docs-mobile-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
}

/* Legal pages use main.container-prose; give the prose page top rhythm. */
main.container-prose { padding-top: var(--space-7); padding-bottom: var(--space-8); }

/* Docs landing pages use main.docs-index instead of main.doc. */
main.docs-index { padding-bottom: var(--space-8); }
