:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #6c776e;
  --soft: #99a29a;
  --paper: #f4f2eb;
  --surface: #fcfbf7;
  --surface-2: #eeece4;
  --line: #dddcd3;
  --rail: #111713;
  --rail-soft: #1b241e;
  --accent: #c7f15a;
  --accent-deep: #6d9320;
  --danger: #ef5d4f;
  --blue: #4d83d8;
  --shadow: 0 24px 70px rgba(19, 28, 22, 0.12);
  --sidebar: 282px;
  --topbar: 68px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", SimSun, serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e7ece8;
  --muted: #9aa69d;
  --soft: #748078;
  --paper: #101512;
  --surface: #161d18;
  --surface-2: #1d261f;
  --line: #2c382f;
  --rail: #0a0e0b;
  --rail-soft: #151c17;
  --accent-deep: #b2dc4a;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.reading-progress { position: fixed; z-index: 100; inset: 0 0 auto; height: 3px; background: transparent; }
.reading-progress span { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 16px rgba(199,241,90,.65); transition: width .1s linear; }

.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; color: #e9efe9; background: var(--rail); overflow: hidden; }
.sidebar::before { content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, #000, transparent 75%); }
.sidebar::after { content: ""; position: absolute; width: 230px; height: 230px; left: -110px; bottom: -100px; background: var(--accent); filter: blur(110px); opacity: .09; pointer-events: none; }
.brand { position: relative; display: flex; gap: 12px; align-items: center; padding: 24px 25px 22px; color: inherit; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--rail); background: var(--accent); border-radius: 4px; transform: rotate(3deg); box-shadow: 4px 4px 0 rgba(199,241,90,.16); }
.brand-mark svg { width: 25px; fill: currentColor; }
.brand b { display: block; font-size: 16px; letter-spacing: .12em; }
.brand small { display: block; margin-top: 3px; color: #7f8b82; font-size: 8px; letter-spacing: .16em; }
.chapter-nav { position: relative; flex: 1; min-height: 0; padding: 18px 12px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #344037 transparent; }
.nav-label { margin: 0 13px 10px; color: #6e7a71; font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.chapter-link { position: relative; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 6px; min-height: 48px; padding: 7px 12px; color: #909c93; text-decoration: none; border-radius: 7px; transition: .2s ease; }
.chapter-link:hover { color: #eaf0ea; background: rgba(255,255,255,.045); }
.chapter-link.active { color: #f4f7f4; background: var(--rail-soft); box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.chapter-link.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 22px; background: var(--accent); border-radius: 3px; box-shadow: 0 0 12px rgba(199,241,90,.45); }
.chapter-no { color: #59655c; font: 700 11px/1 var(--sans); letter-spacing: .08em; }
.chapter-link.active .chapter-no { color: var(--accent); }
.chapter-title { font-size: 13px; font-weight: 600; }
.chapter-state { width: 6px; height: 6px; border: 1px solid #4a554d; border-radius: 50%; }
.chapter-state.live { border: 0; background: #536d2a; }
.sidebar-footer { position: relative; padding: 18px 25px 25px; border-top: 1px solid rgba(255,255,255,.09); }
.completion { display: flex; justify-content: space-between; align-items: center; color: #829087; font-size: 10px; letter-spacing: .08em; }
.completion span { display: flex; align-items: center; gap: 7px; }
.completion i { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); }
.completion strong { color: #dbe3dc; font-size: 11px; }
.completion-bar { height: 3px; margin: 10px 0 13px; background: #29322b; overflow: hidden; }
.completion-bar span { display: block; width: 72.72%; height: 100%; background: var(--accent); }
.sidebar-footer p { margin: 0; color: #566159; font: 12px/1.7 var(--serif); }
.sidebar-scrim { display: none; }

.page-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; z-index: 20; top: 0; height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: color-mix(in srgb, var(--paper) 88%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.crumb { min-width: 0; display: flex; gap: 10px; align-items: center; color: var(--soft); font-size: 12px; letter-spacing: .05em; }
.crumb i { font-style: normal; color: var(--line); }
.crumb strong { max-width: 35vw; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.top-actions { display: flex; gap: 9px; align-items: center; }
.icon-button, .search-button { height: 38px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; transition: .2s ease; }
.icon-button { width: 38px; display: grid; place-items: center; padding: 0; }
.icon-button:hover, .search-button:hover { color: var(--ink); border-color: var(--soft); transform: translateY(-1px); }
.icon-button svg, .search-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-button { display: flex; gap: 8px; align-items: center; padding: 0 9px 0 11px; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; color: var(--soft); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; font: 10px var(--sans); box-shadow: 0 1px 0 var(--line); }
.menu-button { display: none; }

.view { min-height: calc(100vh - var(--topbar)); }
.loading-state { height: calc(100vh - var(--topbar)); display: grid; place-content: center; justify-items: center; color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.mine-loader { display: flex; gap: 6px; }
.mine-loader i { width: 8px; height: 8px; background: var(--accent-deep); animation: blink 1s infinite alternate; }
.mine-loader i:nth-child(2) { animation-delay: .2s; }.mine-loader i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { to { opacity: .2; transform: translateY(-4px); } }

.home-view { position: relative; min-height: calc(100vh - var(--topbar)); overflow: hidden; }
.home-view::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 48px 48px; opacity: .26; mask-image: radial-gradient(circle at 78% 24%, #000, transparent 54%); }
.hero { position: relative; max-width: 1120px; margin: 0 auto; padding: clamp(70px, 10vw, 132px) 54px 90px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: center; gap: 7vw; }
.eyebrow { display: flex; gap: 10px; align-items: center; margin: 0 0 20px; color: var(--accent-deep); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 28px; height: 2px; background: currentColor; }
.hero h1 { max-width: 690px; margin: 0; font-size: clamp(52px, 7vw, 92px); line-height: .98; letter-spacing: -.055em; font-weight: 850; }
.hero h1 em { display: block; margin-top: 14px; color: transparent; -webkit-text-stroke: 1.5px var(--ink); font-style: normal; }
.hero-copy { max-width: 580px; margin: 31px 0 34px; color: var(--muted); font: 17px/1.9 var(--serif); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary-cta, .secondary-cta { display: inline-flex; gap: 10px; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 5px; text-decoration: none; font-size: 13px; font-weight: 750; letter-spacing: .04em; transition: .2s ease; }
.primary-cta { color: #141a15; background: var(--accent); box-shadow: 5px 5px 0 var(--ink); }
.primary-cta:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.secondary-cta { border: 1px solid var(--line); background: var(--surface); }
.secondary-cta:hover { border-color: var(--soft); }
.hero-board { position: relative; aspect-ratio: 1; padding: 35px; background: var(--rail); border-radius: 9px; box-shadow: var(--shadow); transform: rotate(2deg); }
.hero-board::before { content: ""; position: absolute; inset: 12px; border: 1px solid #2e3931; }
.mine-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; height: 100%; }
.cell { display: grid; place-items: center; background: #202a23; color: #708076; border: 1px solid #303d33; font-size: 17px; font-weight: 800; }
.cell.open { background: #e9e8e0; border-color: #e9e8e0; }
.cell.n1 { color: #3070c8; }.cell.n2 { color: #44883a; }.cell.n3 { color: #dc4b43; }.cell.n4 { color: #7553b1; }
.cell.flag { color: #111713; background: var(--accent); border-color: var(--accent); }
.board-label { position: absolute; right: -24px; bottom: 36px; padding: 9px 14px; color: #141a15; background: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .14em; transform: rotate(-2deg); }
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 1012px; margin: 0 auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 30px 36px; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat strong { display: block; font-size: 27px; line-height: 1; }
.stat span { display: block; margin-top: 9px; color: var(--soft); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.path-section { position: relative; max-width: 1120px; margin: 0 auto; padding: 90px 54px 110px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 30px; }
.section-heading h2 { margin: 0; font-size: clamp(30px,4vw,48px); letter-spacing: -.04em; }
.section-heading p { max-width: 360px; margin: 0; color: var(--muted); font: 14px/1.8 var(--serif); }
.chapter-cards { display: grid; grid-template-columns: repeat(2,1fr); gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 7px; }
.chapter-card { min-height: 184px; display: flex; flex-direction: column; padding: 27px 29px; background: var(--surface); text-decoration: none; transition: .22s ease; }
.chapter-card:hover { position: relative; z-index: 2; background: var(--rail); color: #edf3ed; box-shadow: 0 0 0 1px var(--rail); }
.card-meta { display: flex; justify-content: space-between; color: var(--soft); font-size: 10px; font-weight: 750; letter-spacing: .12em; }
.chapter-card:hover .card-meta { color: #7f8b82; }
.card-no { color: var(--accent-deep); }
.chapter-card:hover .card-no { color: var(--accent); }
.chapter-card h3 { margin: 27px 0 10px; font-size: 22px; letter-spacing: -.02em; }
.chapter-card p { margin: 0; color: var(--muted); font: 13px/1.65 var(--serif); }
.chapter-card:hover p { color: #98a49b; }
.chapter-card.coming { opacity: .58; pointer-events: none; }

.article-layout { display: grid; grid-template-columns: minmax(0, 780px) 210px; gap: 70px; max-width: 1120px; margin: 0 auto; padding: 70px 48px 110px; }
.article-main { min-width: 0; }
.article-hero { position: relative; margin-bottom: 52px; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.article-index { position: absolute; top: -35px; right: 0; color: var(--surface-2); font-size: clamp(92px, 13vw, 154px); line-height: 1; font-weight: 900; letter-spacing: -.08em; user-select: none; z-index: -1; }
.article-hero h1 { max-width: 680px; margin: 0; font-size: clamp(42px, 6vw, 68px); line-height: 1.08; letter-spacing: -.055em; }
.article-intro { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 26px; color: var(--soft); font-size: 11px; letter-spacing: .08em; }
.article-intro span { display: flex; align-items: center; gap: 8px; }
.article-intro i { width: 5px; height: 5px; background: var(--accent-deep); border-radius: 50%; }
.markdown-body { font: 17px/2 var(--serif); overflow-wrap: break-word; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1 { display: none; }
.markdown-body h2, .markdown-body h3 { position: relative; scroll-margin-top: calc(var(--topbar) + 26px); font-family: var(--sans); letter-spacing: -.025em; }
.markdown-body h2 { margin: 70px 0 24px; padding-top: 18px; font-size: 30px; line-height: 1.3; border-top: 1px solid var(--line); }
.markdown-body h2::before { content: ""; position: absolute; top: -1px; left: 0; width: 48px; height: 3px; background: var(--accent-deep); }
.markdown-body h3 { margin: 45px 0 18px; font-size: 21px; }
.markdown-body .heading-anchor { margin-left: 8px; color: var(--soft); text-decoration: none; opacity: 0; font-weight: 400; }
.markdown-body h2:hover .heading-anchor, .markdown-body h3:hover .heading-anchor { opacity: 1; }
.markdown-body p { margin: 17px 0; }
.markdown-body strong { font-family: var(--sans); font-weight: 780; }
.markdown-body u { text-decoration-color: var(--accent-deep); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.markdown-body a { color: var(--accent-deep); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.markdown-body ul, .markdown-body ol { margin: 19px 0; padding-left: 1.55em; }
.markdown-body li { margin: 6px 0; padding-left: .25em; }
.markdown-body li::marker { color: var(--accent-deep); font-family: var(--sans); font-weight: 800; }
.markdown-body blockquote { margin: 28px 0; padding: 18px 23px; color: var(--muted); background: var(--surface-2); border-left: 3px solid var(--accent-deep); }
.markdown-body code { padding: 2px 6px; background: var(--surface-2); border-radius: 4px; font: .87em ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown-body img { display: inline-block; max-width: min(100%, 680px); height: auto; margin: 9px 7px 9px 0; padding: 7px; vertical-align: middle; background: #fff; border: 1px solid var(--line); border-radius: 5px; cursor: zoom-in; box-shadow: 0 8px 24px rgba(20,28,22,.08); transition: .2s ease; }
.markdown-body img:hover { border-color: var(--soft); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(20,28,22,.14); }
.markdown-body table { width: 100%; margin: 30px 0; border-collapse: collapse; font-family: var(--sans); font-size: 13px; line-height: 1.55; }
.markdown-body th, .markdown-body td { padding: 12px 13px; text-align: left; border: 1px solid var(--line); }
.markdown-body th { background: var(--rail); color: #edf2ed; font-size: 11px; letter-spacing: .04em; }
.markdown-body tr:nth-child(even) td { background: var(--surface-2); }
.math { display: inline-block; max-width: 100%; overflow-x: auto; padding: 0 .12em; color: var(--ink); font-family: "Times New Roman", serif; }
.katex { font-size: 1.03em !important; }
.article-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 78px; padding-top: 30px; border-top: 1px solid var(--line); }
.pager-link { display: flex; flex-direction: column; min-height: 86px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; transition: .2s ease; }
.pager-link:hover { border-color: var(--accent-deep); transform: translateY(-2px); }
.pager-link.next { text-align: right; }
.pager-link small { color: var(--soft); font-size: 9px; font-weight: 750; letter-spacing: .14em; }
.pager-link strong { margin-top: 9px; font-size: 14px; }
.article-toc { position: sticky; top: calc(var(--topbar) + 36px); align-self: start; max-height: calc(100vh - var(--topbar) - 70px); overflow-y: auto; }
.toc-title { margin: 0 0 14px; color: var(--soft); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.toc-link { display: block; padding: 7px 0 7px 13px; color: var(--muted); border-left: 1px solid var(--line); text-decoration: none; font-size: 12px; line-height: 1.45; transition: .18s ease; }
.toc-link.level-3 { padding-left: 25px; font-size: 11px; }
.toc-link:hover, .toc-link.active { color: var(--ink); border-left-color: var(--accent-deep); }
.toc-link.active { font-weight: 700; }

.coming-view { min-height: calc(100vh - var(--topbar)); display: grid; place-content: center; padding: 50px; text-align: center; }
.coming-icon { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 25px; color: var(--rail); background: var(--accent); font-size: 36px; transform: rotate(4deg); box-shadow: 7px 7px 0 var(--ink); }
.coming-view h1 { margin: 0; font-size: clamp(38px,6vw,68px); letter-spacing: -.05em; }
.coming-view p { margin: 18px 0 30px; color: var(--muted); font: 16px/1.8 var(--serif); }

.search-modal, .lightbox { position: fixed; z-index: 80; inset: 0; display: none; background: rgba(6,10,7,.74); backdrop-filter: blur(8px); }
.search-modal.open { display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 30px; }
.search-dialog { width: min(650px, 100%); overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.search-input-wrap { height: 62px; display: flex; gap: 12px; align-items: center; padding: 0 17px; border-bottom: 1px solid var(--line); }
.search-input-wrap svg { flex: 0 0 auto; width: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-input-wrap input { flex: 1; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 16px; }
.search-results { max-height: min(58vh, 510px); overflow-y: auto; padding: 8px; }
.search-empty { min-height: 180px; display: grid; place-content: center; justify-items: center; color: var(--soft); font: 13px var(--sans); }
.search-empty span { font-size: 35px; color: var(--accent-deep); }
.result-link { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 13px; border-radius: 6px; text-decoration: none; }
.result-link:hover, .result-link:focus { background: var(--surface-2); outline: none; }
.result-no { display: grid; place-items: center; width: 35px; height: 35px; color: var(--accent-deep); background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 4px; font-size: 10px; font-weight: 800; }
.result-text strong { display: block; font-size: 13px; }.result-text small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.result-link > small { color: var(--soft); font-size: 10px; }
.lightbox.open { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px; }
.lightbox img { max-width: min(1100px, 92vw); max-height: 78vh; padding: 10px; background: white; border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.lightbox p { margin: 15px 0 0; color: #cbd2cc; font-size: 12px; }
.lightbox-close { position: absolute; top: 24px; right: 28px; width: 42px; height: 42px; color: white; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 50%; font-size: 27px; cursor: pointer; }

@media (max-width: 1050px) {
  .article-layout { grid-template-columns: minmax(0, 760px); justify-content: center; }
  .article-toc { display: none; }
  .hero-grid { grid-template-columns: minmax(0,1fr) 290px; }
}

@media (max-width: 800px) {
  :root { --sidebar: 278px; --topbar: 60px; }
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: 15px 0 50px rgba(0,0,0,.25); }
  body.menu-open .sidebar { transform: none; }
  .sidebar-scrim { position: fixed; z-index: 29; inset: 0; background: rgba(5,8,6,.55); }
  body.menu-open .sidebar-scrim { display: block; }
  .page-shell { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { padding: 0 16px; }
  .crumb span, .crumb i { display: none; }
  .top-actions .search-button span, .top-actions .search-button kbd { display: none; }
  .top-actions .search-button { width: 38px; justify-content: center; padding: 0; }
  .hero { padding: 70px 28px 65px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: clamp(52px, 15vw, 78px); }
  .hero-board { width: min(380px, 90%); margin: 30px auto 0; }
  .home-stats { margin: 0 28px; }
  .stat { padding: 24px 18px; }
  .path-section { padding: 70px 28px 80px; }
  .section-heading { display: block; }.section-heading p { margin-top: 15px; }
  .article-layout { padding: 55px 24px 80px; }
}

@media (max-width: 540px) {
  .hero-copy { font-size: 15px; }
  .hero-board { padding: 26px; }
  .home-stats { grid-template-columns: 1fr; }
  .stat { display: flex; justify-content: space-between; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .stat span { margin: 0; }
  .chapter-cards { grid-template-columns: 1fr; }
  .article-hero { margin-bottom: 38px; }
  .markdown-body { font-size: 16px; line-height: 1.95; }
  .markdown-body h2 { font-size: 25px; }
  .markdown-body img { max-width: 100%; }
  .article-pager { grid-template-columns: 1fr; }
  .lightbox.open { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
