/* ============================================================
   BACKROOMS ARCHIVE · 后室档案库
   A liminal wiki on yellow wallpaper.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #d7c187;
  --bg-deep: #c4ab6e;
  --paper: #fbf3d9;
  --paper-2: #efe1b6;
  --panel: rgba(250, 242, 218, 0.72);
  --panel-solid: #f4e9c9;
  --ink: #211c11;
  --ink-soft: #453a24;
  --muted: #6d5f41;
  --line: rgba(33, 28, 17, 0.18);
  --line-strong: rgba(33, 28, 17, 0.4);
  --accent: #a5681a;
  --accent-strong: #7c4a0e;
  --accent-soft: rgba(165, 104, 26, 0.12);
  --amber: #e0ae52;
  --dark: #16130b;
  --dark-2: #211c11;
  --danger: #9b3a2d;
  --ok: #4d6b3b;
  --shadow: 0 18px 42px rgba(60, 43, 12, 0.16);
  --shadow-sm: 0 2px 0 rgba(33, 28, 17, 0.08);
  --radius: 3px;
  --wrap: 1180px;
  --mono: "Cascadia Mono", "SFMono-Regular", "Consolas", "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14120c;
  --bg-deep: #0d0b07;
  --paper: #1f1b12;
  --paper-2: #262116;
  --panel: rgba(32, 27, 18, 0.78);
  --panel-solid: #221d13;
  --ink: #ece0bb;
  --ink-soft: #cdbd94;
  --muted: #9a8a66;
  --line: rgba(236, 224, 187, 0.16);
  --line-strong: rgba(236, 224, 187, 0.32);
  --accent: #d7a752;
  --accent-strong: #f0c878;
  --accent-soft: rgba(215, 167, 82, 0.1);
  --amber: #d7a752;
  --dark: #0b0906;
  --dark-2: #15110a;
  --danger: #d37666;
  --ok: #9fbd83;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 0 rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% -12%, rgba(255, 250, 220, 0.4), transparent 58%),
    linear-gradient(180deg, rgba(255, 246, 210, 0.16), rgba(255, 246, 210, 0.04) 42%, rgba(64, 44, 12, 0.12)),
    url("/assets/backrooms-wallpaper.jpg");
  background-size: auto, auto, cover;
  background-position: center top, center, center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(215, 167, 82, 0.1), transparent 60%),
    linear-gradient(180deg, rgba(12, 9, 4, 0.56), rgba(10, 7, 3, 0.74) 45%, rgba(5, 4, 2, 0.88)),
    url("/assets/backrooms-wallpaper.jpg");
  background-size: auto, auto, cover;
  background-position: center top, center, center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

a { color: var(--accent-strong); }
a:hover { color: var(--ink); }

img, svg { max-width: 100%; }

.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
.lead { font-size: 16.5px; color: var(--ink-soft); max-width: 760px; }
.pin { color: var(--accent-strong); margin-right: 6px; font-size: 11px; }

kbd {
  font-family: var(--mono);
  font-size: 0.82em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--panel-solid);
  padding: 0 5px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 28px;
}

.main {
  flex: 1;
  padding-top: 34px;
  padding-bottom: 90px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 10000;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
}

.skip-link:focus { left: 12px; top: 12px; }

/* Atmosphere overlays */
.grain,
.flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9990;
}

.grain {
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image:
    repeating-radial-gradient(circle at 17% 32%, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px);
  background-size: 5px 5px;
}

html[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: 0.18; }

.flicker {
  z-index: 9991;
  background: rgba(255, 244, 200, 0.16);
  opacity: 0.24;
  animation: flicker 11s infinite;
}

html[data-theme="dark"] .flicker { background: rgba(255, 226, 150, 0.05); opacity: 0.2; }

@keyframes flicker {
  0%, 100% { opacity: 0.18; }
  4% { opacity: 0.34; }
  5% { opacity: 0.12; }
  6% { opacity: 0.3; }
  42% { opacity: 0.16; }
  43% { opacity: 0.02; }
  44% { opacity: 0.24; }
  71% { opacity: 0.14; }
  72% { opacity: 0.4; }
  73% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .flicker, .ticker-track, .dot { animation: none !important; }
}

/* ---------------------------------------------------------- topbar */

.topbar {
  background: var(--dark);
  color: #cdbd94;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  border-bottom: 1px solid rgba(224, 174, 82, 0.28);
  position: relative;
  z-index: 60;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 31px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.status, .topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.topbar .dim { color: #8b7c5b; }
.sep { color: #5e5339; }

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(224, 174, 82, 0.8);
  animation: pulse 4s infinite;
  flex: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.clock { color: #a99872; }

.linkbtn {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted rgba(224, 174, 82, 0.5);
  text-underline-offset: 3px;
}

.linkbtn:hover { color: #f0d394; }

/* ---------------------------------------------------------- nav */

.nav {
  position: sticky;
  top: 0;
  z-index: 55;
  background: rgba(239, 227, 190, 0.9);
  border-bottom: 1px solid var(--line-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html[data-theme="dark"] .nav { background: rgba(20, 17, 11, 0.92); }

.nav-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 72px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  flex: none;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--ink);
  flex: none;
}

.brand-mark i { position: absolute; display: block; }
.brand-mark i:nth-child(1) { inset: 5px 5px 5px 5px; border: 1px solid var(--ink); border-right: 0; border-bottom: 0; }
.brand-mark i:nth-child(2) { inset: 11px 11px 5px 5px; border: 1px solid var(--accent); border-left: 0; border-top: 0; }
.brand-mark i:nth-child(3) { width: 7px; height: 7px; right: 5px; bottom: 5px; background: var(--accent); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 14px; letter-spacing: 0.2em; font-weight: 800; }
.brand-text span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.34em; color: var(--muted); margin-top: 3px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13.5px;
}

.nav-link {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.nav-link.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.nav-search {
  position: relative;
  width: clamp(170px, 18vw, 250px);
  margin-left: auto;
  flex: none;
}

.nav-search input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 251, 236, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  border-radius: var(--radius);
}

html[data-theme="dark"] .nav-search input { background: rgba(0, 0, 0, 0.24); }

.nav-search input::placeholder { color: var(--muted); }

.nav-search button {
  position: absolute;
  right: 0;
  top: 0;
  height: 36px;
  width: 34px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.nav-search button:hover { color: var(--ink); background: var(--accent-soft); }

.suggest {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 88vw;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 80;
  max-height: 380px;
  overflow: auto;
}

.suggest[hidden] { display: none; }

.suggest-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 4px 10px;
  padding: 8px 9px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
}

.suggest-item:hover, .suggest-item:focus-visible {
  background: var(--accent-soft);
  border-color: var(--line);
  outline: none;
}

.suggest-kind {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  padding-top: 2px;
}

.suggest-title { font-size: 13px; font-weight: 600; grid-column: 2; }
.suggest-sub { font-size: 11px; color: var(--muted); grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  font-size: 12.5px;
}

.nav-userlink {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  text-decoration: none;
  max-width: 140px;
}

.nav-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-userlink:hover { color: var(--ink); }

.noclip-link {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-decoration: none;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  padding: 5px 8px;
  border-radius: 2px;
  transition: 0.15s;
}

.noclip-link:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.3;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
  box-shadow: 0 8px 18px rgba(50, 36, 10, 0.16);
  color: var(--ink);
}

.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff8e2; }

.btn-ghost { background: transparent; box-shadow: none; border-color: var(--line); }
.btn-ghost:hover { background: var(--accent-soft); }

.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 12px 24px; font-size: 14.5px; }

.btn:focus-visible, .linkbtn:focus-visible, .nav-search input:focus-visible, .nav-search button:focus-visible,
a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.link-more {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--accent-strong);
  white-space: nowrap;
}
.link-more:hover { text-decoration: underline; }

/* ---------------------------------------------------------- hero */

.hero {
  position: relative;
  padding: 54px 0 0;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  z-index: -1;
  right: -8%;
  top: -30%;
  width: 720px;
  height: 560px;
  background:
    radial-gradient(ellipse at center, rgba(255, 236, 175, 0.85), rgba(255, 220, 130, 0.25) 45%, transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

html[data-theme="dark"] .hero-glow {
  background: radial-gradient(ellipse at center, rgba(224, 174, 82, 0.14), transparent 68%);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 52px;
  align-items: center;
}

.kicker {
  font-size: 10.5px;
  letter-spacing: 0.24em;
  color: var(--accent-strong);
  text-transform: uppercase;
  margin: 0 0 18px;
}

.hero-title {
  position: relative;
  margin: 0;
  font-size: clamp(54px, 8.2vw, 106px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--ink);
}

.hero-title::before,
.hero-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
}

.hero-title::before {
  color: #a34a24;
  clip-path: inset(0 0 58% 0);
  transform: translate(2px, -1px);
}

.hero-title::after {
  color: #55633a;
  clip-path: inset(60% 0 0 0);
  transform: translate(-2px, 1px);
}

html[data-theme="dark"] .hero-title::before { color: #c06a3f; }
html[data-theme="dark"] .hero-title::after { color: #8d9a68; }

.hero-sub {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.5em;
  color: var(--accent-strong);
  margin: 18px 0 0;
}

.hero-lead {
  max-width: 570px;
  margin: 20px 0 0;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  align-items: center;
}

.hero-hint {
  margin: 18px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.hero-panel {
  background: var(--dark-2);
  border: 1px solid rgba(224, 174, 82, 0.34);
  box-shadow: var(--shadow);
  color: #e5d6ac;
  padding: 20px 22px 16px;
  position: relative;
}

.hero-panel::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: var(--amber);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: #cdb179;
  border-bottom: 1px solid rgba(224, 174, 82, 0.24);
  padding-bottom: 12px;
}

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

.stat-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(224, 174, 82, 0.16);
}

.stat-list li:last-child { border-bottom: 0; }
.stat-label { font-size: 12px; color: #b7a67e; letter-spacing: 0.04em; }
.stat-value { font-size: 21px; color: #f3e4b8; letter-spacing: 0.06em; }

.panel-foot {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(224, 174, 82, 0.2);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #8d7c57;
}

.ticker {
  margin-top: 46px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  padding: 8px 0;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

html[data-theme="dark"] .ticker { background: rgba(0, 0, 0, 0.12); }

.ticker-track {
  display: inline-flex;
  gap: 52px;
  white-space: nowrap;
  animation: ticker 52s linear infinite;
}

.ticker-track span::before { content: "◇ "; color: var(--accent); }

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------------------------------------------------------- sections / cards */

.section { margin-top: 72px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-head h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.section-kicker {
  margin: 0 0 7px;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--accent-strong);
}

.section-head.small { margin-bottom: 16px; align-items: center; }
.section-head.small h2 { font-size: 21px; }
.section-head .mono.dim { font-size: 10.5px; letter-spacing: 0.04em; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
  position: relative;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 2px;
  background: var(--accent);
  opacity: 0.55;
}

.page-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.page-card h3 {
  margin: 13px 0 4px;
  font-size: 18px;
  line-height: 1.35;
}

.card-sub {
  margin: 0 0 8px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.card-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-foot {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-foot .mono { font-size: 9.5px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-decoration: none;
  line-height: 1.4;
}

html[data-theme="dark"] .chip { background: rgba(255, 255, 255, 0.04); }

.chip-ghost { opacity: 0.6; letter-spacing: 0.12em; }
.chip-pin { color: var(--accent-strong); border-color: var(--accent); }
.chip-kind { color: var(--accent-strong); border-color: rgba(165, 104, 26, 0.4); }

.diff {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  line-height: 1.4;
  color: var(--muted);
}

.diff b { font-weight: 700; }
.diff span { opacity: 0.8; }
.diff-none { color: var(--muted); border-style: dashed; }
.diff-0 { color: #4d6b3b; }
.diff-1 { color: #6b7428; }
.diff-2 { color: #8a6316; }
.diff-3 { color: #a0541f; }
.diff-4 { color: #9b3a2d; }
.diff-5 { color: #6d1f1f; }

html[data-theme="dark"] .diff-0 { color: #9cba80; }
html[data-theme="dark"] .diff-1 { color: #c1c477; }
html[data-theme="dark"] .diff-2 { color: #d7b362; }
html[data-theme="dark"] .diff-3 { color: #d9915c; }
html[data-theme="dark"] .diff-4 { color: #d37666; }
html[data-theme="dark"] .diff-5 { color: #b45a5a; }

.tag-list { display: inline-flex; flex-wrap: wrap; gap: 0 10px; }
.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--accent-strong);
  text-decoration: none;
  white-space: nowrap;
}
.tag:hover { text-decoration: underline; }
.tag.active { text-decoration: underline; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; }
.tag-cloud .tag {
  border: 1px solid var(--line);
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 10.5px;
}
.tag-cloud .tag:hover, .tag-cloud .tag.active { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px 24px;
}

.feed { list-style: none; margin: 0; padding: 0; }
.feed-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.feed-item:last-child { border-bottom: 0; }
.feed-kind { font-size: 9px; letter-spacing: 0.1em; color: var(--accent-strong); }
.feed-title { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-title:hover { color: var(--accent-strong); text-decoration: underline; }
.feed-meta { font-size: 9.5px; white-space: nowrap; }

.hot-list { display: flex; flex-direction: column; }
.hot-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  text-decoration: none;
  color: var(--ink);
}
.hot-item:last-child { border-bottom: 0; }
.hot-title { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.hot-item:hover .hot-title { color: var(--accent-strong); }
.hot-meta { font-size: 9.5px; }

.step-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.step-num {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent-strong);
}

.step-card h3 { margin: 0; font-size: 20px; }
.step-card p { margin: 0; font-size: 13px; color: var(--ink-soft); flex: 1; }
.step-card .link-more { margin-top: 6px; }

.cta-banner {
  margin-top: 80px;
  padding: 34px 38px;
  background: var(--dark-2);
  color: #e9dbb4;
  border: 1px solid rgba(224, 174, 82, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  position: relative;
  overflow: hidden;
}

.cta-banner::before {
  content: "";
  position: absolute;
  right: -10%;
  top: -80%;
  width: 520px;
  height: 420px;
  background: radial-gradient(ellipse, rgba(224, 174, 82, 0.16), transparent 65%);
  pointer-events: none;
}

.cta-banner h2 { margin: 4px 0 8px; font-size: 29px; color: #f2e6c3; }
.cta-banner p { margin: 0; font-size: 13.5px; color: #b3a37d; max-width: 540px; }
.cta-banner .kicker { color: var(--amber); margin-bottom: 6px; }
.cta-banner .btn-primary { background: var(--amber); color: #19150c; border-color: var(--amber); }
.cta-banner .btn-primary:hover { background: #f0c978; border-color: #f0c978; }
.cta-banner .btn { background: transparent; color: #e9dbb4; border-color: rgba(224, 174, 82, 0.35); box-shadow: none; }
.cta-banner .btn:hover { border-color: var(--amber); color: #f6e9c4; }

/* ---------------------------------------------------------- index / filters */

.index-head { padding: 22px 0 8px; border-bottom: 1px solid var(--line-strong); }
.index-head h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.index-head .lead { margin: 16px 0 0; }
.index-head .hero-actions { margin: 22px 0 24px; }

.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 24px 0 12px;
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.16);
  color: var(--ink-soft);
  font-size: 12.5px;
  text-decoration: none;
  transition: 0.12s;
}

.chip-link span {
  font-family: var(--mono);
  font-size: 9.5px;
  opacity: 0.6;
}

.chip-link:hover { border-color: var(--line-strong); color: var(--ink); }
.chip-link.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-link.active span { opacity: 0.7; }

.filter-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.filter-search { display: flex; gap: 0; }
.filter-search input {
  width: 190px;
  height: 33px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}
.filter-search .btn { box-shadow: none; }

.sort-form { display: flex; align-items: center; gap: 6px; }
.sort-form label { font-size: 9.5px; letter-spacing: 0.12em; color: var(--muted); }
.sort-form select {
  height: 33px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.active-filter { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.result-line { margin: 20px 0 14px; font-size: 10px; letter-spacing: 0.08em; }

.empty {
  border: 1px dashed var(--line-strong);
  padding: 50px 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.12);
}
.empty-mark { font-size: 34px; color: var(--accent); opacity: 0.7; margin-bottom: 8px; }
.empty h3 { margin: 0 0 6px; font-size: 20px; }
.empty p { margin: 0 auto 18px; max-width: 420px; }

/* ---------------------------------------------------------- article */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-strong); text-decoration: underline; }
.crumb-sep { color: var(--line-strong); }

.page-head { padding-bottom: 26px; border-bottom: 1px solid var(--line-strong); }
.page-head.compact { padding-bottom: 20px; }
.page-kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-head h1 {
  margin: 16px 0 0;
  font-size: clamp(32px, 4.4vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.page-title-en {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}
.page-head .lead { margin: 16px 0 0; }
.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 18px;
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 52px;
  margin-top: 34px;
  align-items: start;
}

.article-col { min-width: 0; }
.article-body { max-width: 780px; }
.article-tags { margin: 26px 0 0; }
.article-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }

.toc {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.14);
  padding: 16px 20px;
  margin: 0 0 30px;
}
.toc-title { font-size: 9px; letter-spacing: 0.2em; color: var(--accent-strong); margin-bottom: 8px; }
.toc-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 26px; }
.toc-list li { margin: 0 0 5px; break-inside: avoid; }
.toc-list a {
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.toc-list a:hover { color: var(--accent-strong); border-bottom-color: var(--accent); }
.toc-3 { padding-left: 14px; font-size: 0.94em; }
.toc-3 a { color: var(--muted); }

/* prose */

.prose { font-size: 15.5px; line-height: 1.85; color: var(--ink); }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose h2 {
  margin: 42px 0 14px;
  padding-bottom: 8px;
  font-size: 25px;
  line-height: 1.3;
  border-bottom: 1px solid var(--line);
  letter-spacing: -0.01em;
}
.prose h3 { margin: 30px 0 10px; font-size: 19.5px; }
.prose h4 { margin: 24px 0 8px; font-size: 17px; }
.prose p { margin: 0 0 17px; }
.prose a { color: var(--accent-strong); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { color: var(--ink); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose ul, .prose ol { margin: 0 0 17px; padding-left: 24px; }
.prose li { margin: 5px 0; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  margin: 22px 0;
  padding: 13px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.18);
  color: var(--ink-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.07);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 2px;
}
html[data-theme="dark"] .prose code { background: rgba(255, 255, 255, 0.06); }
.prose pre.code {
  margin: 22px 0;
  padding: 17px 19px;
  background: #17140c;
  color: #e7d8ae;
  border: 1px solid #322a1a;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.75;
}
.prose pre.code code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.prose hr { border: 0; border-top: 1px dashed var(--line-strong); margin: 32px 0; }
.prose .table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--line); }
.prose table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.prose th {
  text-align: left;
  padding: 9px 13px;
  background: rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
}
.prose td { padding: 9px 13px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose .wikilink {
  color: var(--accent-strong);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.prose.small { font-size: 14px; line-height: 1.75; }
.prose.small p { margin-bottom: 10px; }
.prose.small h2 { font-size: 19px; margin-top: 24px; }

/* sidebar */

.sidebar { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.infobox { background: var(--panel); border: 1px solid var(--line); }
.infobox-head {
  padding: 10px 14px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  background: rgba(0, 0, 0, 0.055);
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}
html[data-theme="dark"] .infobox-head { background: rgba(255, 255, 255, 0.035); }
.infobox dl { margin: 0; padding: 10px 16px 13px; }
.infobox dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.infobox dl > div:last-child { border-bottom: 0; }
.infobox dt { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted); flex: none; }
.infobox dd { margin: 0; font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.infobox dd .mono { font-size: 9.5px; }
.infobox dd .diff { font-size: 8.5px; }
.infobox-cite {
  border-top: 1px solid var(--line);
  padding: 11px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.infobox-cite span { font-size: 8.5px; letter-spacing: 0.14em; }
.infobox-cite code {
  font-family: var(--mono);
  font-size: 10px;
  padding: 5px 7px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
html[data-theme="dark"] .infobox-cite code { background: rgba(255, 255, 255, 0.05); }

.side-box {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px 18px;
}
.box-title {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--accent-strong);
  margin-bottom: 10px;
}
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.side-list li:last-child { border-bottom: 0; }
.side-list a { color: var(--ink-soft); text-decoration: none; }
.side-list a:hover { color: var(--accent-strong); text-decoration: underline; }
.side-box p { margin: 0 0 8px; font-size: 12.5px; color: var(--ink-soft); }
.side-box .link-more { font-size: 10px; }

.side-warning {
  background: rgba(155, 58, 45, 0.09);
  border-color: rgba(155, 58, 45, 0.35);
  position: relative;
}
.side-warning .dot { position: absolute; top: 18px; right: 16px; background: var(--danger); box-shadow: 0 0 8px rgba(155, 58, 45, 0.6); }
.side-warning p { font-family: var(--sans); font-size: 12px; line-height: 1.7; color: var(--ink-soft); padding-right: 16px; }
.side-warning a { font-family: var(--mono); font-size: 9.5px; color: var(--danger); text-decoration: none; }
.side-warning a:hover { text-decoration: underline; }

/* comments */

.comments, .related-inline { margin-top: 56px; }
.comment { padding: 20px 0; border-bottom: 1px dashed var(--line); }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.comment-author { display: flex; flex-direction: column; line-height: 1.3; }
.comment-author a { font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: none; }
.comment-author a:hover { color: var(--accent-strong); }
.comment-author span { font-size: 9px; letter-spacing: 0.03em; }
.comment-body { padding-left: 38px; }
.comment-empty { padding: 20px 0; }
.comment-form {
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px 20px;
}
.comment-form label { display: block; font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
.comment-form textarea { width: 100%; min-height: 104px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.form-foot .mono { font-size: 9.5px; }
.login-prompt {
  margin-top: 24px;
  border: 1px dashed var(--line-strong);
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
}
.login-prompt p { margin: 0; }

.related-inline .page-card { padding: 18px; }
.related-inline .page-card h3 { font-size: 16px; }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 2px;
  color: #f6efdd;
  text-transform: uppercase;
  overflow: hidden;
}
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-lg { width: 82px; height: 82px; font-size: 32px; border-width: 2px; }
.av-0 { background: #7c4a3f; }
.av-1 { background: #556b2f; }
.av-2 { background: #7a6030; }
.av-3 { background: #3f5f6b; }
.av-4 { background: #6a4a6f; }
.av-5 { background: #82552c; }
.av-6 { background: #4d5a3a; }
.av-7 { background: #6b3f3f; }
.av-8 { background: #38585a; }
.av-9 { background: #5c5430; }
.av-10 { background: #5a4660; }
.av-11 { background: #4c4c4c; }

/* 统一账户同步过来的头像：用图片填满色块 */
.avatar-img { padding: 0; background: rgba(0, 0, 0, 0.06); }
.avatar-img img { display: block; width: 100%; height: 100%; object-fit: cover; }

.user-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 12.5px;
}
.user-link:hover { color: var(--accent-strong); text-decoration: underline; }

/* ---------------------------------------------------------- community */

.community-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  margin-top: 26px;
  align-items: start;
}
.community-main { min-width: 0; }
.community-head { border-bottom: 1px solid var(--line-strong); padding-bottom: 6px; }

.thread-list { border-top: 1px solid var(--line-strong); margin-top: 22px; }
.thread-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 118px 90px;
  gap: 16px;
  align-items: center;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s;
}
.thread-row:hover { background: rgba(255, 255, 255, 0.2); }
html[data-theme="dark"] .thread-row:hover { background: rgba(255, 255, 255, 0.03); }
.thread-cat { font-size: 9px; letter-spacing: 0.06em; color: var(--accent-strong); }
.thread-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.thread-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.thread-meta { font-size: 9px; }
.thread-counts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 9px;
  color: var(--muted);
}
.thread-last { font-size: 9px; text-align: right; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.cat-list li:last-child { border-bottom: 0; }
.cat-list a { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); text-decoration: none; }
.cat-list a:hover { color: var(--accent-strong); }
.cat-list span { font-size: 10.5px; line-height: 1.5; }

.active-list { list-style: none; margin: 0; padding: 0; }
.active-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.active-list li:last-child { border-bottom: 0; }
.active-list a { display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--ink-soft); font-size: 12.5px; }
.active-list a:hover { color: var(--accent-strong); }
.active-list .mono { font-size: 9px; }

.post-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  padding: 30px 34px;
  margin-top: 6px;
}
.post-head h1 { margin: 14px 0 0; font-size: clamp(26px, 3.4vw, 38px); line-height: 1.2; letter-spacing: -0.02em; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.post-meta .mono { font-size: 9.5px; }
.post-card .prose { margin-top: 22px; }

.replies { margin-top: 40px; }
.reply-list { border-top: 1px solid var(--line); }
.reply {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.reply-rail { font-size: 9px; letter-spacing: 0.08em; color: var(--muted); padding-top: 5px; border-right: 1px solid var(--line); }
.reply-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.reply-author { font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; }
.reply-author:hover { color: var(--accent-strong); }
.reply-head .mono { font-size: 9px; }
.reply-main { min-width: 0; }
.reply-empty { padding: 22px 0; }

.reply-form {
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 20px;
}
.reply-form > label { display: block; font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
.reply-form textarea { width: 100%; min-height: 110px; }
.thread-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 34px; flex-wrap: wrap; }

/* ---------------------------------------------------------- editor */

.editor-page .page-head { margin-bottom: 22px; }
.editor-form { margin-top: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field label, .auth-form label, .form-card label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.req { color: var(--accent-strong); }

input, textarea, select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: rgba(255, 252, 240, 0.62);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 9px 11px;
  width: 100%;
}
html[data-theme="dark"] input, html[data-theme="dark"] textarea, html[data-theme="dark"] select {
  background: rgba(0, 0, 0, 0.22);
}
input[readonly] { opacity: 0.72; cursor: not-allowed; }
textarea { resize: vertical; min-height: 46px; line-height: 1.65; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); background: rgba(255, 252, 240, 0.9); }
html[data-theme="dark"] input:focus, html[data-theme="dark"] textarea:focus, html[data-theme="dark"] select:focus { background: rgba(0, 0, 0, 0.35); }
.hint { margin: 0; font-size: 10.5px; color: var(--muted); }

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
  margin-top: 18px;
  align-items: stretch;
}
.editor-pane, .preview-pane { display: flex; flex-direction: column; min-width: 0; }
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  flex-wrap: wrap;
}
.md-btn {
  min-width: 30px;
  height: 27px;
  padding: 0 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
}
.md-btn:hover { border-color: var(--line); background: var(--paper); color: var(--ink); }
.toolbar-hint { margin-left: auto; font-size: 8.5px; letter-spacing: 0.14em; padding-right: 4px; }
#editorBody {
  flex: 1;
  min-height: 540px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  padding: 14px 16px;
  resize: vertical;
  border-radius: 0;
}
.editor-foot { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px; font-size: 9px; }

.preview-pane {
  border: 1px solid var(--line-strong);
  background: var(--panel);
}
.preview-head {
  padding: 8px 14px;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--accent-strong);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.04);
  flex: none;
}
.preview {
  padding: 18px 20px;
  overflow: auto;
  min-height: 120px;
}
.editor-layout .preview { min-height: 540px; max-height: 760px; }
.inline-preview { margin-top: 12px; }
.inline-preview .preview { min-height: 90px; max-height: 340px; }
.inline-preview .preview:empty { display: none; }

.help-details {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.help-details summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.help-card { padding: 2px 18px 16px; }
.help-title { font-size: 9px; letter-spacing: 0.16em; color: var(--accent-strong); margin-bottom: 6px; }
.help-list { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.9; color: var(--ink-soft); }
.help-list code { font-family: var(--mono); font-size: 11px; background: rgba(0, 0, 0, 0.06); padding: 1px 5px; }
html[data-theme="dark"] .help-list code { background: rgba(255, 255, 255, 0.06); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 11px 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  font-size: 12.5px;
  margin-bottom: 20px;
}
.alert-error { border-color: rgba(155, 58, 45, 0.5); background: rgba(155, 58, 45, 0.1); color: var(--danger); }
.alert-warn { border-color: rgba(165, 104, 26, 0.5); background: var(--accent-soft); color: var(--ink-soft); }
.alert a { color: inherit; font-family: var(--mono); font-size: 10.5px; margin-left: auto; }

.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 900px;
}
.form-card textarea { font-family: var(--mono); font-size: 13px; line-height: 1.75; }

/* history */

.history-list { margin-top: 10px; border-top: 1px solid var(--line-strong); }
.history-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.history-rail { position: relative; }
.history-rail::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: -24px;
  width: 1px;
  background: var(--line);
}
.history-item:last-child .history-rail::before { display: none; }
.history-dot {
  position: absolute;
  left: 0;
  top: 5px;
  width: 9px;
  height: 9px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
}
.history-dot.current { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.history-when { font-size: 9px; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 3px; }
.history-main h3 { margin: 0 0 3px; font-size: 14.5px; }
.history-main h3 a { color: var(--ink); text-decoration: none; }
.history-main h3 a:hover { color: var(--accent-strong); text-decoration: underline; }
.history-main p { margin: 0; font-size: 12px; }
.history-main > span { font-size: 9px; }
.history-actions { display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------- profile */

.profile-head {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 10px 0 28px;
  border-bottom: 1px solid var(--line-strong);
}
.profile-main { min-width: 0; }
.profile-main h1 { margin: 2px 0 4px; font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: -0.02em; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; font-size: 9.5px; letter-spacing: 0.04em; }
.profile-bio { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-soft); max-width: 700px; }
.profile-main .kicker { margin-bottom: 5px; }

.bio-form { margin-top: 14px; max-width: 620px; }
.bio-form label { display: block; font-size: 9px; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 6px; }
.bio-row { display: flex; gap: 8px; }
.bio-row input { flex: 1; }

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  margin-top: 34px;
  align-items: start;
}
.activity-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.activity-list li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.activity-kind { font-size: 8.5px; letter-spacing: 0.08em; color: var(--accent-strong); }
.activity-title { font-size: 13.5px; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-title:hover { color: var(--accent-strong); text-decoration: underline; }
.activity-extra { grid-column: 2; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { grid-column: 3; grid-row: 1; font-size: 9px; white-space: nowrap; }

/* ---------------------------------------------------------- search / recent / about */

.big-search { display: flex; gap: 10px; margin: 22px 0 10px; max-width: 740px; }
.big-search input { flex: 1; font-size: 16px; padding: 12px 16px; }
.search-section { margin-top: 32px; }
.search-list { border-top: 1px solid var(--line-strong); }
.result {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
}
.result:hover { background: rgba(255, 255, 255, 0.18); }
html[data-theme="dark"] .result:hover { background: rgba(255, 255, 255, 0.03); }
.result-kind { font-size: 9px; letter-spacing: 0.06em; color: var(--accent-strong); }
.result-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.result-main b { font-size: 13.5px; font-weight: 600; }
.result-main span { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result > .mono { font-size: 9px; white-space: nowrap; }
.search-hints { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 26px; }

.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 52px;
  margin-top: 20px;
  align-items: start;
}
.about-prose { max-width: 780px; }
.about-prose h1 { font-size: clamp(32px, 4vw, 44px); border-bottom: 0; margin-top: 0; }

.error-page { padding: 54px 0 10px; }
.error-page h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.1; margin: 10px 0 16px; letter-spacing: -0.03em; }
.error-page .lead { max-width: 680px; }
.error-grid { margin-top: 44px; }

/* ---------------------------------------------------------- auth */

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 430px) minmax(0, 1fr);
  gap: 64px;
  align-items: start;
  padding: 30px 0;
  max-width: 1000px;
  margin: 0 auto;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  padding: 32px;
  position: relative;
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 60px;
  height: 3px;
  background: var(--accent);
}
.auth-head h1 { margin: 4px 0 8px; font-size: 36px; letter-spacing: -0.02em; }
.auth-head p { margin: 0; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.auth-form .field label { font-size: 9.5px; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-alt { margin: 18px 0 0; font-size: 12.5px; text-align: center; }
.auth-side { padding-top: 60px; }
.auth-quote blockquote {
  margin: 14px 0 16px;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  font-size: 22px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.auth-quote .mono { font-size: 9px; letter-spacing: 0.16em; }

/* ---------------------------------------------------------- footer */

.footer {
  margin-top: 40px;
  background: #12100a;
  color: #b4a47e;
  border-top: 1px solid rgba(224, 174, 82, 0.25);
  font-size: 12px;
  padding: 38px 0 30px;
}
.foot-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 36px;
}
.foot-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.foot-logo { width: 28px; height: 28px; flex: none; }
.foot-name {
  display: block;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #eadcb6;
}
.foot-dim { color: #8f815e; font-weight: 500; margin-left: 1px; }
.foot-brand p { margin: 10px 0 0; font-size: 11.5px; line-height: 1.75; color: #8f815e; max-width: 420px; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 10px 18px; padding-top: 6px; }
.foot-nav a { color: #c4b184; text-decoration: none; font-size: 10.5px; letter-spacing: 0.04em; }
.foot-nav a:hover { color: #f0d394; text-decoration: underline; }
.foot-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid rgba(224, 174, 82, 0.18);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #7c6f51;
}
.foot-mono { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; }

/* ---------------------------------------------------------- misc */

.draft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  margin-bottom: 10px;
}
.draft-banner span { flex: 1; min-width: 180px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 10000;
  background: var(--dark-2);
  color: #f0e2bb;
  border: 1px solid var(--amber);
  padding: 9px 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  box-shadow: var(--shadow);
}

body.is-noclipping .main { animation: noclip-shift 0.42s steps(4) both; }
body.is-noclipping .flicker { opacity: 0.85; background: rgba(255, 240, 180, 0.5); }
body.is-noclipping .nav { filter: invert(1) hue-rotate(100deg); }

@keyframes noclip-shift {
  0% { transform: translate(0, 0) scale(1); filter: none; }
  30% { transform: translate(-8px, 4px) scale(1.01); filter: invert(1) hue-rotate(90deg); }
  60% { transform: translate(10px, -6px) scale(0.995); filter: invert(0.6) contrast(2); }
  100% { transform: translate(0, 0) scale(1); filter: invert(1) hue-rotate(180deg); }
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .nav-inner { gap: 18px; }
  .nav-links { gap: 14px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); gap: 34px; }
  .page-layout, .about-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 34px; }
  .community-layout, .profile-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 30px; }
}

@media (max-width: 900px) {
  .nav-inner { flex-wrap: wrap; gap: 12px 18px; padding-top: 12px; padding-bottom: 12px; }
  .nav-links { order: 4; width: 100%; gap: 20px; overflow-x: auto; padding-bottom: 2px; }
  .nav-search { order: 3; margin-left: auto; flex: 1; width: auto; max-width: 320px; }
  .nav-user { order: 2; }
  .hero-grid { grid-template-columns: 1fr; gap: 30px; }
  .hero-panel { max-width: 460px; }
  .two-col { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-layout, .community-layout, .profile-layout, .about-layout { grid-template-columns: 1fr; gap: 34px; }
  .sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-layout .preview { min-height: 160px; max-height: 420px; }
  #editorBody { min-height: 380px; }
  .auth-page { grid-template-columns: 1fr; gap: 30px; max-width: 520px; }
  .auth-side { padding-top: 0; }
  .foot-inner { flex-direction: column; gap: 22px; }
  .foot-inner > * { max-width: 100%; }
  .foot-nav { width: 100%; }
  .foot-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .cta-banner { flex-direction: column; align-items: flex-start; padding: 28px; }
  .toc-list { columns: 1; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .main { padding-top: 22px; padding-bottom: 60px; }
  .topbar-right .clock, .topbar .dim, .topbar .status { display: none; }
  .topbar-inner { justify-content: center; }
  .brand-text b { font-size: 12px; }
  .brand-text span { font-size: 8.5px; letter-spacing: 0.24em; }
  .nav-search { max-width: none; flex-basis: 100%; order: 5; }
  .nav-links { order: 4; justify-content: space-between; gap: 8px; font-size: 12px; }
  .nav-user .nav-username { display: none; }
  .nav-userlink { gap: 0; }
  .hero { padding-top: 34px; }
  .hero-title { font-size: clamp(36px, 10vw, 52px); }
  .hero-sub { letter-spacing: 0.34em; font-size: 11px; }
  .hero-lead { font-size: 15px; }
  .hero-actions .btn-lg { padding: 10px 16px; font-size: 13px; }
  .hero-panel { padding: 16px 18px 12px; }
  .ticker { margin-top: 30px; }
  .section { margin-top: 48px; }
  .section-head h2 { font-size: 22px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 30px; }
  .sidebar { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .field-wide { grid-column: auto; }
  .thread-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 13px 4px; }
  .thread-cat { grid-column: 1; }
  .thread-main { grid-column: 1; }
  .thread-counts { grid-column: 2; grid-row: 1 / span 2; }
  .thread-last { display: none; }
  .post-card { padding: 22px 18px; }
  .post-card .prose { font-size: 14.8px; }
  .reply { grid-template-columns: 1fr; gap: 6px; }
  .reply-rail { display: none; }
  .history-item { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .history-rail { display: none; }
  .history-actions { grid-column: 1 / -1; }
  .profile-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .av-lg { width: 64px; height: 64px; font-size: 24px; }
  .result { grid-template-columns: 56px minmax(0, 1fr); }
  .result > .mono { display: none; }
  .search-hints { grid-template-columns: 1fr; }
  .auth-card { padding: 22px 18px; }
  .editor-toolbar .toolbar-hint { display: none; }
  .editor-form .form-actions .btn-lg { width: 100%; }
  .filterbar { align-items: stretch; }
  .filter-tools { width: 100%; }
  .filter-search { flex: 1; }
  .filter-search input { width: 100%; }
  .foot-nav { gap: 8px 14px; }
  .cta-banner h2 { font-size: 24px; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-head.small { flex-direction: row; }
}

/* ------------------------------------------------------------
   LEVEL REGISTRY / 层级总表
   ------------------------------------------------------------ */

.levels-table-wrap {
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  overflow-x: auto;
}

.levels-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.levels-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  text-align: left;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.levels-table td {
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.levels-table tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.025); }
html[data-theme="dark"] .levels-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
.levels-table tbody tr:hover { background: var(--accent-soft); }

.lv-id { width: 108px; font-size: 11.5px; letter-spacing: 0.04em; white-space: nowrap; }
.lv-name { min-width: 180px; }
.lv-title { display: block; color: var(--ink); }
.lv-sub { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.lv-cluster { width: 92px; font-size: 10px; letter-spacing: 0.08em; white-space: nowrap; }
.lv-archive { width: 110px; text-align: right; white-space: nowrap; }
.lv-link { font-size: 11.5px; color: var(--accent-strong); text-decoration: none; border-bottom: 1px solid transparent; }
.lv-link:hover { border-bottom-color: currentColor; }
.lv-empty { padding: 40px 14px; text-align: center; color: var(--muted); }

.lv-status {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid currentColor;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.lv-status.ok { color: var(--ok); background: rgba(77, 107, 59, 0.08); }
.lv-status.dim { color: var(--muted); background: transparent; }
.lv-status.danger { color: var(--danger); background: rgba(155, 58, 45, 0.08); }
.lv-status.muted { color: var(--muted); border-style: dashed; background: transparent; }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 11px;
}

.pager-step {
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  text-decoration: none;
  transition: 0.12s;
}
.pager-step:hover { background: var(--accent-soft); color: var(--ink); }
.pager-step.disabled { opacity: 0.35; pointer-events: none; }

.pager-nums { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.pager-num {
  min-width: 30px;
  padding: 6px 7px;
  text-align: center;
  border: 1px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
}
.pager-num:hover { border-color: var(--line-strong); color: var(--ink); }
.pager-num.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pager-gap { padding: 0 3px; color: var(--muted); }

.levels-note {
  margin-top: 26px;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}
.levels-note b { display: block; margin-bottom: 8px; font-size: 9.5px; letter-spacing: 0.16em; color: var(--accent-strong); }
.levels-note p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.75; color: var(--ink-soft); }
.levels-note p:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .levels-table { min-width: 560px; }
  .levels-table thead th, .levels-table td { padding: 8px 10px; }
  .levels-head .hero-actions { flex-wrap: wrap; }
  .pager { justify-content: center; }
  .levels-note { padding: 14px; }
}
