:root {
  --bg: #f4f2ec; --surface: #fbfaf6; --surface-2: #ebe8df; --ink: #1d211f;
  --muted: #6d726d; --line: #d9d6cc; --accent: #e55b2d; --accent-strong: #bd3e17;
  --sage: #1e5f50; --sage-soft: #dfece4; --code: #18201d;
  --shadow: 0 20px 60px rgba(35, 42, 37, .1);
  --serif: Georgia, "Noto Serif SC", "Songti SC", serif;
  --sans: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #151917; --surface: #1c211e; --surface-2: #252b27; --ink: #eef1ec;
  --muted: #a9b0aa; --line: #353c37; --accent: #ff7a48; --accent-strong: #ff9b74;
  --sage: #78b9a7; --sage-soft: #21382f; --code: #0e120f; --shadow: 0 24px 70px rgba(0, 0, 0, .32);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.65; transition: background .25s, color .25s; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; background: var(--ink); color: var(--bg); padding: .7rem 1rem; }
.skip-link:focus { top: 1rem; }
.topbar { min-height: 76px; padding: 0 clamp(1.2rem, 4vw, 4.5rem); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 50; }
.brand { display: inline-flex; gap: .72rem; align-items: center; width: max-content; }
.brand-mark { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: white; font: 700 1.2rem var(--serif); box-shadow: inset 0 0 0 5px rgba(255,255,255,.18); }
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand strong { letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: .69rem; margin-top: .12rem; }
.topnav { display: flex; gap: 2rem; align-items: center; font-size: .9rem; }
.topnav a { color: var(--muted); position: relative; padding: 1.55rem 0; }
.topnav a:hover, .topnav a.active { color: var(--ink); }
.topnav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.icon-button { margin-left: auto; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 50%; cursor: pointer; }
.icon-button:hover { border-color: var(--accent); color: var(--accent); }
.hero { max-width: 1440px; margin: 0 auto; padding: clamp(3.8rem, 8vw, 8rem) clamp(1.2rem, 6vw, 6rem) 5rem; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, .9fr); align-items: center; gap: clamp(3rem, 7vw, 8rem); min-height: 690px; }
.kicker { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; margin: 0 0 1rem; }
.hero h1 { font: 400 clamp(3.2rem, 6vw, 6.5rem)/1.02 var(--serif); letter-spacing: -.055em; margin: 0; max-width: 850px; }
.hero h1 em { color: var(--accent); font-style: italic; }
.hero-lede { color: var(--muted); max-width: 640px; font-size: 1.06rem; margin: 2rem 0; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .72rem 1.25rem; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-weight: 700; font-size: .9rem; }
.button.primary { background: var(--ink); color: var(--bg); }
.button.primary:hover { background: var(--accent); color: white; }
.button.ghost { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button.ghost:hover { border-color: var(--ink); }
.hero-panel { position: relative; aspect-ratio: 1; max-width: 560px; width: 100%; margin: auto; border-radius: 50%; border: 1px solid var(--line); background: radial-gradient(circle at 50% 45%, var(--surface) 0 26%, transparent 26.4%), repeating-radial-gradient(circle, transparent 0 20%, var(--line) 20.2% 20.5%, transparent 20.7% 33%); }
.hero-panel::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; background: conic-gradient(from 40deg, var(--sage-soft), transparent 32%, color-mix(in srgb, var(--accent) 18%, transparent) 58%, transparent 80%); animation: drift 14s linear infinite; }
.java-glyph { position: absolute; inset: 32%; border-radius: 50%; display: flex; justify-content: center; align-items: center; gap: .35rem; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); z-index: 2; transform: rotate(-4deg); }
.java-glyph b { font: italic 700 clamp(2.6rem, 6vw, 5.8rem) var(--serif); color: var(--accent); }
.java-glyph span { font-size: clamp(1.5rem, 3vw, 2.6rem); color: var(--muted); }
.metric { position: absolute; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); padding: .8rem 1rem; min-width: 116px; z-index: 3; }
.metric strong, .metric span { display: block; }
.metric strong { font: 600 1.7rem var(--serif); }
.metric span { color: var(--muted); font-size: .72rem; }
.metric-a { top: 8%; left: 6%; transform: rotate(-4deg); }
.metric-b { right: 0; top: 34%; transform: rotate(3deg); }
.metric-c { bottom: 8%; left: 12%; transform: rotate(2deg); }
@keyframes drift { to { transform: rotate(360deg); } }
.dashboard-shell { max-width: 1280px; margin: 0 auto; padding: 2rem clamp(1.2rem, 4vw, 3rem) 6rem; }
.section-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin-bottom: 2rem; }
.section-heading h2 { margin: 0; font: 400 clamp(2.2rem, 4vw, 3.6rem) var(--serif); letter-spacing: -.04em; }
.section-heading.small h2 { font-size: 2rem; }
.progress-summary { width: min(300px, 35vw); display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; font-size: .8rem; color: var(--muted); }
.progress-summary strong { color: var(--ink); }
.progress-track { grid-column: 1 / -1; height: 4px; background: var(--line); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s ease; }
.course-stages { border-top: 1px solid var(--line); }
.stage { display: grid; grid-template-columns: 230px 1fr; gap: 2rem; padding: 2.25rem 0; border-bottom: 1px solid var(--line); }
.stage-title { position: sticky; top: 100px; align-self: start; }
.stage-number { font: italic 400 3rem var(--serif); color: var(--accent); }
.stage-title h3 { font: 500 1.4rem var(--serif); margin: .5rem 0 .2rem; }
.stage-title p { font-size: .78rem; color: var(--muted); margin: 0; }
.chapter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chapter-card { position: relative; display: grid; grid-template-columns: 52px 1fr auto; gap: 1rem; padding: 1.25rem; min-height: 150px; border: 1px solid transparent; border-bottom-color: var(--line); transition: .2s ease; }
.chapter-card:nth-child(odd) { border-right-color: var(--line); }
.chapter-card:hover { background: var(--surface); border-color: var(--line); transform: translateY(-2px); box-shadow: var(--shadow); z-index: 2; }
.chapter-index { font: italic 400 1.2rem var(--serif); color: var(--accent); }
.chapter-card h4 { margin: 0 0 .42rem; font-size: 1rem; }
.chapter-card p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.chapter-topics { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.chapter-topics span { font-size: .65rem; background: var(--surface-2); color: var(--muted); padding: .2rem .45rem; }
.chapter-arrow { color: var(--muted); }
.chapter-card.done::after { content: "✓"; position: absolute; right: 1.2rem; bottom: 1rem; color: var(--sage); font-weight: 800; }
.library-strip { background: var(--ink); color: var(--bg); padding: clamp(4rem, 8vw, 7rem) max(1.2rem, calc((100vw - 1220px) / 2)); }
.library-intro { max-width: 760px; margin-bottom: 2.5rem; }
.library-intro h2 { font: 400 clamp(2.4rem, 5vw, 4.7rem) var(--serif); margin: 0; letter-spacing: -.04em; }
.library-intro p:last-child { color: color-mix(in srgb, var(--bg) 65%, transparent); max-width: 620px; }
.library-cards { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); }
.library-card { min-height: 230px; padding: 1.4rem; border-right: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); display: flex; flex-direction: column; align-items: flex-start; transition: .2s; }
.library-card:last-child { border-right: 0; }
.library-card:hover { background: color-mix(in srgb, var(--bg) 9%, transparent); }
.library-card.featured { background: var(--accent); color: white; }
.library-card span { font-size: .65rem; letter-spacing: .16em; opacity: .7; }
.library-card h3 { font: 500 1.35rem var(--serif); margin: 2.4rem 0 .5rem; }
.library-card p { font-size: .75rem; opacity: .65; margin: 0; }
.library-card b { margin-top: auto; font-size: .76rem; }
.site-footer { min-height: 120px; padding: 2rem max(1.2rem, calc((100vw - 1220px) / 2)); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .78rem; }
.search-dialog { width: min(720px, calc(100vw - 2rem)); max-height: min(720px, calc(100vh - 2rem)); padding: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 35px 100px rgba(0,0,0,.3); }
.search-dialog::backdrop { background: rgba(15, 20, 17, .58); backdrop-filter: blur(5px); }
.search-head { display: flex; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); font-weight: 700; }
.search-head button { border: 0; background: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
#global-search { width: calc(100% - 2.4rem); margin: 1.2rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 1rem; border-radius: 5px; outline: none; }
#global-search:focus { border-color: var(--accent); }
.search-hint { color: var(--muted); font-size: .75rem; padding: 0 1.2rem 1rem; }
.search-results { overflow: auto; max-height: 480px; border-top: 1px solid var(--line); }
.search-result { display: block; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.search-result:hover { background: var(--surface-2); }
.search-result b { color: var(--accent); font-size: .72rem; }
.search-result strong { display: block; margin: .2rem 0; }
.search-result p { margin: 0; color: var(--muted); font-size: .78rem; }
.search-empty { padding: 2rem; text-align: center; color: var(--muted); }
.topbar.compact { position: fixed; width: 100%; }
.reader-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.reader-actions .icon-button { margin-left: 0; }
.reading-progress { position: fixed; z-index: 60; top: 75px; left: 0; right: 0; height: 2px; }
.reading-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.reader-shell { padding-top: 76px; display: grid; grid-template-columns: 260px minmax(0, 820px) 240px; gap: clamp(2rem, 5vw, 5rem); max-width: 1460px; margin: 0 auto; }
.chapter-sidebar, .toc-sidebar { position: sticky; top: 76px; align-self: start; height: calc(100vh - 76px); overflow: auto; padding: 2rem 0 2rem 1.2rem; }
.toc-sidebar { padding: 2rem 1.2rem 2rem 0; }
.back-link { color: var(--muted); font-size: .74rem; display: inline-block; margin-bottom: 2rem; }
.back-link:hover { color: var(--accent); }
.sidebar-label { text-transform: uppercase; font-size: .66rem; color: var(--muted); letter-spacing: .16em; margin-bottom: .7rem; font-weight: 800; }
.chapter-menu { display: grid; }
.chapter-menu a { display: grid; grid-template-columns: 30px 1fr; gap: .5rem; padding: .5rem .7rem; color: var(--muted); font-size: .75rem; border-left: 2px solid transparent; }
.chapter-menu a:hover, .chapter-menu a.active { color: var(--ink); background: var(--surface); border-left-color: var(--accent); }
.chapter-menu a span { font-family: var(--serif); color: var(--accent); }
.sidebar-library { display: block; margin: 2rem .8rem 0 0; padding: 1rem; background: var(--sage-soft); color: var(--sage); }
.sidebar-library span, .sidebar-library b { display: block; font-size: .7rem; }
.sidebar-library b { margin-top: .3rem; }
.lesson { min-width: 0; padding: 5rem 0 6rem; }
.lesson-header { border-bottom: 1px solid var(--line); padding-bottom: 2.5rem; margin-bottom: 3.2rem; }
.lesson-stage { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.lesson-header h1 { margin: .8rem 0 1rem; font: 400 clamp(2.6rem, 5vw, 4.7rem)/1.12 var(--serif); letter-spacing: -.045em; }
.lesson-header p { color: var(--muted); max-width: 620px; }
.lesson-meta { display: flex; gap: 1rem; color: var(--muted); font-size: .72rem; margin-top: 1.5rem; }
.prose { font-size: 1rem; }
.prose h1 { display: none; }
.prose h2 { scroll-margin-top: 110px; font: 500 2rem/1.3 var(--serif); margin: 3.5rem 0 1.4rem; padding-top: .5rem; letter-spacing: -.02em; }
.prose h3 { scroll-margin-top: 110px; font: 700 1.25rem/1.4 var(--sans); margin: 2.6rem 0 1rem; }
.prose h4 { scroll-margin-top: 110px; font-size: 1rem; margin-top: 2rem; }
.prose p, .prose li { color: color-mix(in srgb, var(--ink) 88%, var(--muted)); }
.prose a { color: var(--sage); text-decoration: underline; text-underline-offset: 3px; }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.8rem auto; border-radius: 4px; background: white; }
.prose blockquote { margin: 1.5rem 0; padding: .8rem 1.2rem; border-left: 3px solid var(--accent); background: var(--surface); color: var(--muted); }
.prose blockquote p { margin: .2rem 0; }
.prose code { font: .88em Consolas, "SFMono-Regular", monospace; color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); padding: .12em .3em; border-radius: 3px; }
.prose pre { overflow: auto; background: var(--code); color: #e9eee9; padding: 1.1rem; border-radius: 6px; line-height: 1.55; box-shadow: inset 3px 0 var(--accent); }
.prose pre code { background: none; color: inherit; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .85rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .65rem .8rem; text-align: left; }
.prose th { background: var(--surface-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }
.loading-card { padding: 2rem; background: var(--surface); color: var(--muted); }
.toc-card { border-left: 1px solid var(--line); padding-left: 1rem; }
#lesson-toc { display: grid; gap: .18rem; max-height: 66vh; overflow: auto; }
#lesson-toc a { padding: .22rem 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
#lesson-toc a.level-3 { padding-left: .8rem; }
#lesson-toc a.level-4 { padding-left: 1.35rem; }
#lesson-toc a:hover, #lesson-toc a.active { color: var(--accent); }
.bookmark-current { margin-top: 1.5rem; width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .6rem; font-size: .72rem; cursor: pointer; }
.chapter-resources { margin-top: 5rem; border-top: 1px solid var(--line); padding-top: 3rem; }
.resource-mini-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.resource-mini { display: grid; grid-template-columns: 38px 1fr; gap: .7rem; padding: .8rem; border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.resource-mini span { display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: .58rem; font-weight: 800; }
.resource-mini strong { display: block; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resource-mini small { color: var(--muted); font-size: .65rem; }
.lesson-pager { border-top: 1px solid var(--line); margin-top: 4rem; padding-top: 2rem; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; font-size: .8rem; }
.lesson-pager a:last-child { text-align: right; }
.pdf-study-card h2 { margin-top: 0; }
.pdf-actions { display: flex; gap: .6rem; margin: 1.5rem 0; }
.pdf-frame { width: 100%; height: min(76vh, 920px); border: 1px solid var(--line); background: white; }
.resources-page { max-width: 1260px; margin: 0 auto; padding: 4rem clamp(1.2rem, 4vw, 3rem) 7rem; }
.resources-hero { padding: 2rem 0 4rem; }
.resources-hero h1 { font: 400 clamp(3rem, 6vw, 6rem) var(--serif); margin: 0; letter-spacing: -.05em; }
.resources-hero > p:not(.kicker) { color: var(--muted); max-width: 660px; }
.archive-stats { display: flex; gap: 2rem; margin-top: 2rem; flex-wrap: wrap; }
.archive-stats span { color: var(--muted); font-size: .76rem; }
.archive-stats b { color: var(--ink); font: 600 1.5rem var(--serif); margin-right: .35rem; }
.resource-browser { background: var(--surface); border: 1px solid var(--line); }
.resource-toolbar { display: grid; grid-template-columns: 1fr 200px 160px; gap: .7rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.resource-search { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); background: var(--bg); padding: 0 .8rem; }
.resource-search input, .resource-toolbar select { width: 100%; border: 0; outline: 0; background: var(--bg); color: var(--ink); padding: .75rem; }
.resource-filter-row { display: flex; justify-content: space-between; padding: .65rem 1rem; color: var(--muted); font-size: .72rem; border-bottom: 1px solid var(--line); }
.resource-filter-row button { border: 0; background: none; color: var(--accent); cursor: pointer; }
.resource-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 90px 70px 34px; gap: .9rem; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.resource-row:hover { background: var(--surface-2); }
.file-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: .56rem; font-weight: 800; text-transform: uppercase; }
.file-info { min-width: 0; }
.file-info strong, .file-info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info strong { font-size: .8rem; }
.file-info small { color: var(--muted); font-size: .65rem; }
.file-chapter, .file-size { color: var(--muted); font-size: .68rem; }
.file-open { color: var(--accent); font-size: 1rem; text-align: right; }
.load-more { display: flex; margin: 1.5rem auto; }
@media (max-width: 1100px) {
  .reader-shell { grid-template-columns: 220px minmax(0, 1fr); padding-right: 2rem; }
  .toc-sidebar { display: none; }
  .lesson { padding-right: 1rem; }
  .library-cards { grid-template-columns: repeat(2, 1fr); }
  .library-card:nth-child(2) { border-right: 0; }
  .library-card:nth-child(-n+2) { border-bottom: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); }
}
@media (max-width: 800px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 1rem; }
  .topnav { display: none; }
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 4rem; }
  .hero-panel { max-width: 460px; }
  .stage { grid-template-columns: 1fr; }
  .stage-title { position: static; display: grid; grid-template-columns: 70px 1fr; }
  .stage-title p { grid-column: 2; }
  .chapter-grid { grid-template-columns: 1fr; }
  .chapter-card:nth-child(odd) { border-right-color: transparent; }
  .section-heading { align-items: start; }
  .progress-summary { width: 140px; }
  .reader-shell { display: block; padding: 76px 1.1rem 0; }
  .chapter-sidebar { position: static; height: auto; padding: 1.5rem 0 0; }
  .chapter-menu { display: flex; overflow-x: auto; padding-bottom: .5rem; }
  .chapter-menu a { flex: 0 0 auto; border-left: 0; border-bottom: 2px solid transparent; }
  .chapter-menu a.active { border-bottom-color: var(--accent); }
  .chapter-menu a b { display: none; }
  .sidebar-library, .sidebar-label, .back-link { display: none; }
  .lesson { padding: 2.5rem 0 5rem; }
  .resource-toolbar { grid-template-columns: 1fr 1fr; }
  .resource-search { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .hero { padding: 3.2rem 1.1rem; }
  .hero h1 { font-size: 3.2rem; }
  .hero-panel { width: 94%; }
  .metric { min-width: 90px; padding: .6rem .7rem; }
  .metric strong { font-size: 1.25rem; }
  .chapter-card { grid-template-columns: 38px 1fr; }
  .chapter-arrow { display: none; }
  .library-cards { grid-template-columns: 1fr; }
  .library-card { border-right: 0; border-bottom: 1px solid color-mix(in srgb, var(--bg) 18%, transparent); min-height: 190px; }
  .library-card:last-child { border-bottom: 0; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .lesson-header h1 { font-size: 2.7rem; }
  .lesson-pager { grid-template-columns: 1fr 1fr; }
  .lesson-pager .button { grid-column: 1 / -1; grid-row: 1; }
  .resource-mini-grid { grid-template-columns: 1fr; }
  .resource-row { grid-template-columns: 40px minmax(0, 1fr) 30px; }
  .file-chapter, .file-size { display: none; }
  .resource-toolbar { grid-template-columns: 1fr; }
  .resource-search { grid-column: auto; }
  .archive-stats { gap: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
