/* ==========================================================================
   次元町 CIYUAN TOWN · 协议与政策
   纯文本排版，不加装饰：浅灰底 + 白卡 + 细分隔线，层级只靠字号与间距
   ========================================================================== */

:root {
  --bg: #f6f7f8;
  --card: #ffffff;
  --text: #303436;
  --text-2: #5f666b;
  --text-3: #9aa0a5;
  --line: #f0f1f2;
  --line-strong: #e6e8ea;
  --chevron: #c6cacd;
  --accent: #0284c7;
  --radius: 12px;
  --max-index: 680px;
  --max-doc: 1080px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- 顶栏 --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-strong);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  font-size: 15px;
}

.brand:hover {
  text-decoration: none;
}

.topbar-nav {
  display: none;
  margin-left: auto;
  gap: 4px;
}

.topbar-nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
}

.topbar-nav a:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  text-decoration: none;
}

.topbar-nav a[aria-current="page"] {
  color: var(--text);
}

/* 文档页顶栏：返回 + 标题 */

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  margin-left: -4px;
  padding: 4px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 14px;
}

.back:hover {
  color: var(--text);
  text-decoration: none;
}

.back svg {
  width: 20px;
  height: 20px;
}

.back-label {
  display: none;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* ------------------------------------------------------------ 列表首页 --- */

.wrap-index {
  max-width: var(--max-index);
  margin: 0 auto;
  padding: 28px 16px calc(40px + var(--safe-b));
}

.page-head {
  padding: 8px 4px 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 600;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--text-3);
  font-size: 13px;
}

.legal-list {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.legal-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.16s ease;
}

.legal-row:last-child {
  border-bottom: 0;
}

.legal-row:hover {
  background: #fafbfb;
  text-decoration: none;
}

.legal-row:active {
  background: #f5f6f7;
}

.legal-row .row-label {
  min-width: 0;
}

.legal-row .row-desc {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

.chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--chevron);
  transition: transform 0.18s ease, color 0.18s ease;
}

.legal-row:hover .chevron {
  transform: translateX(2px);
  color: var(--text-3);
}

.page-note {
  margin: 18px 4px 0;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.8;
}

.page-note strong {
  color: var(--text-2);
  font-weight: 500;
}

/* -------------------------------------------------------------- 文档页 --- */

.doc-shell {
  max-width: var(--max-doc);
  margin: 0 auto;
  padding: 18px 14px calc(48px + var(--safe-b));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.toc {
  display: none;
}

.doc {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 24px 18px 30px;
}

.doc > h1 {
  margin: 4px 0 10px;
  font-size: 20px;
  line-height: 1.45;
  font-weight: 600;
}

.doc-meta {
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.9;
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
}

.doc-meta span + span::before {
  content: "·";
  margin-right: 14px;
  color: var(--line-strong);
}

@media (max-width: 560px) {
  .doc-meta span + span::before {
    content: none;
    margin: 0;
  }
}

.doc h2 {
  margin: 34px 0 10px;
  font-size: 16.5px;
  line-height: 1.6;
  font-weight: 600;
  color: #24282a;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.doc h3 {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: #2c3033;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.doc p {
  margin: 0 0 12px;
  color: #3c4145;
}

.doc ul,
.doc ol {
  margin: 0 0 14px;
  padding-left: 1.35em;
  color: #3c4145;
}

.doc li {
  margin: 6px 0;
}

.doc li::marker {
  color: var(--text-3);
}

.doc strong {
  font-weight: 600;
  color: #24282a;
}

.doc code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #f2f4f5;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: #3c4145;
}

/* 导语 / 提示块 */

/* 导语与提示：不加底色、不加边框，只作为正文段落 */

.lead {
  margin: 0 0 20px;
  color: var(--text);
}

.lead p:last-child,
.callout p:last-child {
  margin-bottom: 0;
}

.callout {
  margin: 14px 0 16px;
  color: var(--text-2);
  font-size: 14px;
}

/* 表格 */

.table-wrap {
  margin: 14px 0 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13.5px;
  line-height: 1.7;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}

th {
  color: var(--text-2);
  font-weight: 500;
  border-bottom: 1px solid var(--line-strong);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td:first-child {
  color: #24282a;
  font-weight: 500;
}

.table-hint {
  margin: -8px 0 18px;
  color: var(--text-3);
  font-size: 12px;
}

.table-scroll-tip {
  margin: 0 0 8px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
}

.table-scroll-tip[hidden] {
  display: none;
}

@media (min-width: 768px) {
  .table-scroll-tip {
    display: none;
  }
}

/* 移动端目录（<details>） */

.toc-mobile {
  margin: 0 0 16px;
  font-size: 14px;
}

.toc-mobile > summary {
  padding: 4px 0;
  cursor: pointer;
  color: var(--text-3);
  font-size: 13px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toc-mobile > summary::-webkit-details-marker {
  display: none;
}

.toc-mobile > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: rotate(45deg);
}

.toc-mobile[open] > summary::after {
  margin-top: 2px;
  transform: rotate(225deg);
}

.toc-mobile ol {
  margin: 0;
  padding: 6px 0 10px 1.35em;
  font-size: 13.5px;
}

.toc-mobile li {
  margin: 5px 0;
}

.toc-mobile a {
  color: var(--text-2);
}

/* 文档页脚 */

.doc-foot {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--text-3);
  font-size: 12.5px;
}

.doc-foot a {
  color: var(--text-2);
}

.doc-foot a:hover {
  color: var(--accent);
}

/* 侧边目录（≥1100px） */

@media (min-width: 1100px) {
  .doc-shell {
    grid-template-columns: 232px minmax(0, 1fr);
    padding: 30px 28px 72px;
    gap: 34px;
  }

  .toc {
    display: block;
    position: sticky;
    top: calc(var(--topbar-h) + 26px);
    max-height: calc(100vh - var(--topbar-h) - 60px);
    overflow-y: auto;
    padding-right: 6px;
  }

  .toc-title {
    margin: 0 0 8px;
    padding-left: 12px;
    color: var(--text-3);
    font-size: 12px;
  }

  .toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 1px solid var(--line-strong);
  }

  .toc li {
    margin: 0;
  }

  .toc a {
    display: block;
    margin-left: -1px;
    padding: 6px 10px 6px 12px;
    border-left: 2px solid transparent;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.6;
    transition: color 0.15s ease, border-color 0.15s ease;
  }

  .toc a:hover {
    color: var(--text);
    text-decoration: none;
  }

  .toc a.is-active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 500;
  }

  .toc-mobile {
    display: none;
  }

  .doc {
    padding: 44px 56px 52px;
  }

  .doc > h1 {
    font-size: 22px;
  }

  .doc h2 {
    margin-top: 40px;
    font-size: 18px;
  }

  .doc p,
  .doc li {
    font-size: 15.5px;
  }
}

/* 平板 */

@media (min-width: 768px) {
  .topbar {
    padding: 0 24px;
  }

  .topbar-nav {
    display: flex;
  }

  .wrap-index {
    padding: 44px 24px calc(56px + var(--safe-b));
  }

  .page-head {
    padding-bottom: 22px;
  }

  .page-head h1 {
    font-size: 28px;
  }

  .legal-row {
    min-height: 62px;
    padding: 14px 22px;
    font-size: 15.5px;
  }

  .doc-shell {
    padding: 24px 24px calc(56px + var(--safe-b));
  }

  .doc {
    padding: 36px 40px 44px;
  }

  .doc > h1 {
    font-size: 22px;
  }

  .back {
    font-size: 13.5px;
    padding: 4px 6px 4px 4px;
  }

  .back-label {
    display: inline;
  }
}

/* 大屏列表页 */

@media (min-width: 1024px) {
  .wrap-index {
    padding-top: 72px;
  }
}

/* ---------------------------------------------------------------- 页脚 --- */

.site-footer {
  padding: 8px 16px calc(26px + var(--safe-b));
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.9;
  text-align: center;
}

.site-footer a {
  color: var(--text-3);
}

.site-footer a:hover {
  color: var(--text-2);
  text-decoration: none;
}

.footer-sep {
  margin: 0 6px;
  color: var(--line-strong);
}

/* ---------------------------------------------------------------- 打印 --- */

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .toc,
  .toc-mobile,
  .site-footer,
  .doc-foot {
    display: none !important;
  }

  .doc-shell {
    display: block;
    padding: 0;
    max-width: none;
  }

  .doc {
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  a {
    color: #000;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
