:root {
  --canvas: #f7f7f7;
  --sheet: #ffffff;
  --ink: #222222;
  --body: #3f3f3f;
  --muted: #6a6a6a;
  --line: #e4e4e4;
  --brand: #00a67e;
  --brand-ink: #063d30;
  --brand-soft: #e6f7f1;
  --danger: #8f1d1d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.6;
}

a { color: var(--brand-ink); }

button, input { font: inherit; color: inherit; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
}

.skip:focus {
  left: 12px;
  background: var(--sheet);
  padding: 8px 12px;
  z-index: 40;
}

.wrap {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

.masthead-row { padding-top: 12px; }

.brand-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.seal {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-ink);
  color: #f7f7f7;
  font-size: 18px;
  font-weight: 600;
}

.wordmark strong {
  font-size: 17px;
  font-weight: 650;
}

.parent-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.parent-link:hover { color: var(--brand-ink); }

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin: 8px 0 0;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.nav a {
  flex: 0 0 auto;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--body);
  text-decoration: none;
  font-size: 14px;
}

.nav a:hover { background: var(--canvas); color: var(--ink); }

.nav a.is-on,
.nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}

.page { padding: 20px 0 48px; }

.sheet {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 8px;
}

.page h1,
.article h1,
.preview-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 40em;
}

.search {
  display: block;
  margin-top: 16px;
}

.search span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.search input {
  width: 100%;
  height: 48px;
  border: 1px solid #cfcfcf;
  border-radius: 10px;
  background: #fff;
  padding: 0 14px;
}

.search input:focus {
  outline: 2px solid var(--brand);
  border-color: var(--brand);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.filter-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  width: 2.5em;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

.chip:hover { border-color: #bdbdbd; }

.chip.is-on {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
  color: #fff;
}

.chip .count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.chip.is-on .count { color: rgba(255, 255, 255, 0.8); }

.block-title {
  margin: 18px 0 0;
  font-size: 15px;
  font-weight: 650;
}

.crumb {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.crumb a { color: inherit; }

.docs {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.doc-title {
  color: inherit;
  text-decoration: none;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.4;
}

.doc-title:hover { color: var(--brand-ink); }

.doc-sum,
.doc-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.doc-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
  border-color: #cfcfcf;
}

.btn:hover { opacity: 0.92; }

.btn:focus-visible,
.chip:focus-visible,
.nav a:focus-visible,
.doc-title:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.empty {
  padding: 8px 0 20px;
  color: var(--muted);
}

.more {
  margin: 4px 0 16px;
}

.colophon {
  border-top: 1px solid var(--line);
  background: var(--sheet);
  padding: 20px 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.colophon a {
  color: var(--ink);
  text-decoration: none;
  margin-right: 14px;
}

.colophon p { margin: 8px 0 0; }

.article {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 24px 8px;
}

.article h2 {
  margin: 28px 0 8px;
  font-size: 18px;
}

.article p { color: var(--body); }

.plain { padding-left: 1.2em; }

.plain li { margin: 8px 0; }

.article .btn { margin: 8px 0 20px; }

.preview-shell { padding-bottom: 28px; }

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.preview-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.preview-meta a { color: inherit; }

.preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.preview-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.frame-wrap {
  min-height: 70vh;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.frame-wrap iframe {
  width: 100%;
  height: 78vh;
  min-height: 640px;
  border: 0;
  background: #fff;
}

.related {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 6px;
}

.related h2 {
  margin: 8px 0;
  font-size: 14px;
}

.related ol {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.related li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.related a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.related a:hover { color: var(--brand-ink); }

.related .tiny {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.status {
  margin: 0;
  padding: 28px;
  color: var(--body);
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal-back.open { display: flex; }

.modal {
  width: min(520px, 100%);
  background: var(--sheet);
  border-radius: var(--radius);
  padding: 20px;
}

.modal h2 { margin: 0 0 8px; font-size: 20px; }

.modal p { margin: 0 0 12px; color: var(--muted); }

.drive-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px 4px;
  margin-bottom: 10px;
}

.drive-block h3 { margin: 0 0 8px; font-size: 16px; }

.drive-block .btn { margin-bottom: 12px; }

.field {
  background: var(--canvas);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.field a, .field strong { word-break: break-all; }

.drive-missing { margin-bottom: 12px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .page h1,
  .preview-head h1 { font-size: 24px; }

  .doc,
  .preview-head,
  .preview-split {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .preview-head { align-items: flex-start; }

  .doc-actions,
  .preview-actions { justify-content: flex-start; }

  .frame-wrap iframe {
    min-height: 70vh;
    height: 70vh;
  }

  .sheet,
  .article { padding-left: 14px; padding-right: 14px; }
}
