:root {
  --bg: #100e0a; --panel: #171410; --fg: #d9d2c2; --muted: #7a7364;
  --accent: #b3925c; --hairline: #29251c;
  --serif: Georgia, "Nimbus Roman", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Courier New", monospace;
}
[data-theme="light"] {
  --bg: #efece4; --panel: #f7f4ec; --fg: #28231a; --muted: #857c6a;
  --accent: #7a5f33; --hairline: #d5cebc;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--sans); line-height: 1.9; font-size: 16.5px;
  transition: background .3s, color .3s;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M3 1 L17 9 L9.5 10.5 L6 19 Z' fill='%23b3925c' stroke='%23100e0a' stroke-width='1'/%3E%3C/svg%3E") 3 1, auto;
}
a, button, .theme-btn {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M12 1.5 L22.5 12 L12 22.5 L1.5 12 Z' fill='none' stroke='%23b3925c' stroke-width='1.4'/%3E%3Ccircle cx='12' cy='12' r='2' fill='%23b3925c'/%3E%3C/svg%3E") 12 12, pointer;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); opacity: .055;
}
a { color: inherit; text-decoration: none; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px; padding: 18px 32px;
  border-bottom: 1px solid transparent;
  transition: transform .35s ease, background .3s, border-color .3s;
}
.topbar.scrolled {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom-color: var(--hairline);
}
.topbar.tucked { transform: translateY(-110%); }
.topbar .home { display: flex; align-items: center; gap: 14px; color: var(--fg); }
.topbar .home svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; transition: transform .4s; }
.topbar .home:hover svg { transform: rotate(180deg); }
.topbar .brand-en {
  font-family: var(--mono); font-size: 11px; letter-spacing: 4px;
  text-transform: uppercase; color: var(--fg);
}
.topbar .home:hover .brand-en { color: var(--accent); }
.topbar .crumb {
  color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 3px;
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .crumb::before { content: "/ "; color: var(--accent); }
.topbar .crumb a:hover { color: var(--accent); }
.theme-btn {
  margin-left: auto; border: none; background: transparent; color: var(--muted);
  width: 34px; height: 34px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: color .25s;
}
.theme-btn:hover { color: var(--accent); }

/* ---------- home (single viewport) ---------- */
.stage {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  justify-content: center; padding: 64px 6vw 20px;
}
.masthead h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(44px, 11vw, 128px);
  letter-spacing: .18em; line-height: 1.05; margin: 0;
}
.masthead .sub {
  font-family: var(--mono); font-size: 11px; letter-spacing: 6px;
  text-transform: uppercase; color: var(--muted); margin-top: 20px;
}
.masthead .rule { width: 72px; height: 1px; background: var(--accent); margin-top: 28px; }
.portals { margin-top: 5vh; }
.portals a {
  display: flex; align-items: baseline; gap: 4vw;
  padding: 2vh 0; border-bottom: 1px solid var(--hairline);
}
.portals a:first-child { border-top: 1px solid var(--hairline); }
.portals h3 {
  font-family: var(--serif); font-weight: 700; margin: 0;
  font-size: clamp(22px, 3.5vw, 38px); letter-spacing: .3em;
  transition: color .25s, transform .25s;
}
.portals .en {
  font-family: var(--mono); font-size: 10px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--muted);
}
.portals a:hover h3 { color: var(--accent); transform: translateX(12px); }
.stage .colophon { padding: 0; margin-top: 4vh; }
@media (max-height: 760px) {
  .masthead h1 { font-size: clamp(38px, 10vh, 96px); }
  .portals { margin-top: 4vh; }
  .stage .colophon { display: none; }
}

/* ---------- wiki index (dictionary wall) ---------- */
.idx {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 8vw;
}
.idx h1 {
  font-family: var(--serif); font-weight: 700; margin: 0 0 6vh;
  font-size: clamp(40px, 8vw, 96px); letter-spacing: .3em; line-height: 1.1;
}
.idx-row {
  display: flex; align-items: baseline; gap: 4vw;
  padding: 3vh 0; border-bottom: 1px solid var(--hairline);
}
.idx-row:first-of-type { border-top: 1px solid var(--hairline); }
.idx-letter {
  font-family: var(--serif); font-weight: 700; line-height: 1; flex-shrink: 0;
  width: clamp(64px, 8vw, 110px);
  font-size: clamp(44px, 6vw, 76px);
  color: transparent; -webkit-text-stroke: 1px var(--muted);
  transition: -webkit-text-stroke-color .25s;
}
.idx-row:hover .idx-letter { -webkit-text-stroke-color: var(--accent); }
.idx-items a {
  display: block; font-family: var(--serif); font-weight: 700;
  font-size: clamp(18px, 2.2vw, 24px); letter-spacing: .22em; padding: 4px 0;
  transition: color .25s, transform .25s;
}
.idx-items a:hover { color: var(--accent); transform: translateX(10px); }
@media (max-height: 700px) {
  .idx h1 { font-size: clamp(32px, 8vh, 64px); margin-bottom: 4vh; }
  .idx-row { padding: 2vh 0; }
}

/* ---------- article ---------- */
.article { max-width: 720px; margin: 0 auto; padding: 20vh 28px 14vh; }
.article h1 {
  font-family: var(--serif); font-size: clamp(30px, 5vw, 44px); line-height: 1.35;
  margin: 0 0 8vh; padding-bottom: 4vh; border-bottom: 1px solid var(--hairline);
  letter-spacing: .18em;
}
.article h2 {
  font-family: var(--serif); font-size: 23px; margin: 9vh 0 18px; letter-spacing: .15em;
}
.article h2::before { content: "§ "; color: var(--accent); font-weight: 400; }
.article h3 { font-size: 17px; margin: 36px 0 10px; letter-spacing: .1em; }
.article p { margin: 15px 0; }
.article ul, .article ol { padding-left: 24px; margin: 15px 0; }
.article li { margin: 6px 0; }
.article li::marker { color: var(--accent); }
.article blockquote {
  margin: 28px 0; padding: 2px 0 2px 20px; border-left: 1px solid var(--accent);
  color: var(--muted); font-size: 15px;
}
.article blockquote p { margin: 4px 0; }
.article table {
  border-collapse: collapse; margin: 28px 0; width: 100%; font-size: 14.5px;
  border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
.article th, .article td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); text-align: left; }
.article tr:last-child td { border-bottom: none; }
.article th {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--accent);
}
.article code { background: var(--panel); padding: 2px 6px; font-size: .9em; font-family: var(--mono); }
.article strong { color: var(--accent); font-weight: 600; }
.article hr { border: none; border-top: 1px solid var(--hairline); margin: 44px 0; }
.pagenav { display: flex; margin-top: 12vh; border-top: 1px solid var(--hairline); }
.pagenav a {
  flex: 1; padding: 22px 4px; color: var(--muted);
  font-family: var(--serif); font-size: 16px; letter-spacing: .15em;
  transition: color .25s;
}
.pagenav a:hover { color: var(--accent); }
.pagenav a.next { text-align: right; }
.colophon, .article footer {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted);
}
.colophon { padding: 0 6vw 6vh; }
.article footer { margin-top: 8vh; }
@media (max-width: 640px) {
  .masthead h1 { letter-spacing: .1em; }
  .article { padding-top: 14vh; }
  body { font-size: 16px; }
}