/* ==========================================================================
   Stochastic Path — site styles
   Plain CSS on purpose: no Sass toolchain to break the build.
   ========================================================================== */

:root {
  color-scheme: light;

  --ink:        #16181d;
  --ink-soft:   #4a4f59;
  --ink-faint:  #878d99;
  --bg:         #fcfcfa;
  --bg-raise:   #ffffff;
  --rule:       #e4e2dc;
  --rule-soft:  #efedE7;
  --accent:     #3f5d8f;
  --accent-ink: #2c4670;
  --tint:       #eef1f7;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans CJK SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Source Serif Pro",
                Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC",
                "STSong", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;
  --wrap: 66rem;
  --radius: 6px;
  --step: clamp(1rem, 0.6rem + 1.4vw, 1.6rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink:        #e6e5e1;
    --ink-soft:   #a8adb7;
    --ink-faint:  #767c88;
    --bg:         #14161a;
    --bg-raise:   #1b1e24;
    --rule:       #2b2f37;
    --rule-soft:  #23262c;
    --accent:     #8fb0e0;
    --accent-ink: #a9c4ea;
    --tint:       #1e232c;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink:        #e6e5e1;
  --ink-soft:   #a8adb7;
  --ink-faint:  #767c88;
  --bg:         #14161a;
  --bg-raise:   #1b1e24;
  --rule:       #2b2f37;
  --rule-soft:  #23262c;
  --accent:     #8fb0e0;
  --accent-ink: #a9c4ea;
  --tint:       #1e232c;
}

/* --- reset ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg, video, audio, iframe { max-width: 100%; }
img { height: auto; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.25; margin: 0 0 .4em; letter-spacing: -0.01em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--step); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

.dot { margin: 0 .5em; color: var(--ink-faint); }

/* --- header --------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 40;
}

.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 60px; }

.brand { color: var(--ink); font-family: var(--font-serif); font-size: 1.06rem; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 1.35rem; }
.site-nav > a, .nav-group > a {
  color: var(--ink-soft); font-size: .875rem; letter-spacing: .01em; padding: .3rem 0;
  border-bottom: 1.5px solid transparent;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; border-bottom-color: var(--rule); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.nav-group { position: relative; display: flex; align-items: center; }
.nav-submenu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--bg-raise); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: .35rem; min-width: 8rem; display: flex; flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,.09);
  opacity: 0; visibility: hidden; transition: opacity .13s ease, visibility .13s;
}
.nav-group:hover .nav-submenu,
.nav-group:focus-within .nav-submenu { opacity: 1; visibility: visible; }
.nav-submenu a { color: var(--ink-soft); font-size: .85rem; padding: .35rem .6rem; border-radius: 4px; }
.nav-submenu a:hover { background: var(--tint); color: var(--ink); text-decoration: none; border: 0; }

.nav-tools { display: flex; align-items: center; gap: .75rem; padding-left: .35rem; border-left: 1px solid var(--rule); }
.lang-switch { font-size: .8rem; color: var(--ink-faint); padding-left: .75rem; }
.lang-switch:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  background: none; border: 0; padding: .2rem; cursor: pointer; color: var(--ink-faint);
  display: inline-flex; line-height: 0; border-radius: 4px;
}
.theme-toggle:hover { color: var(--ink); }
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .icon-sun { display: none; }
  html:not([data-theme="light"]) .icon-moon { display: inline; }
}

.nav-burger { display: none; }

@media (max-width: 780px) {
  .nav-burger {
    display: flex; flex-direction: column; gap: 4px; margin-left: auto;
    cursor: pointer; padding: .5rem; order: 3;
  }
  .nav-burger span { display: block; width: 20px; height: 1.6px; background: var(--ink-soft); }
  .site-nav {
    order: 4; flex-basis: 100%; margin-left: 0; flex-direction: column; align-items: flex-start;
    gap: .1rem; display: none; padding-bottom: .9rem;
  }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav > a, .nav-group > a { padding: .45rem 0; font-size: .95rem; }
  .nav-group { width: 100%; }
  .nav-submenu {
    position: static; transform: none; opacity: 1; visibility: visible; border: 0;
    box-shadow: none; background: none; padding: 0 0 0 1rem;
  }
  .nav-tools { border-left: 0; padding-left: 0; margin-top: .6rem; }
  .lang-switch { padding-left: 0; }
}

/* --- generic page --------------------------------------------------------- */

.page-content { flex: 1 0 auto; padding: clamp(2rem, 5vw, 3.6rem) 0 4rem; }

.page-head { margin-bottom: 2rem; }
.page-title { font-size: clamp(1.7rem, 1.1rem + 2.3vw, 2.5rem); margin-bottom: .25rem; }
.page-subtitle { color: var(--ink-soft); font-size: 1.02rem; margin: 0; max-width: var(--measure); }
.post-meta { color: var(--ink-faint); font-size: .82rem; margin: 0 0 .6rem; }
.empty { color: var(--ink-faint); font-style: italic; }
.intro { margin-bottom: 2.5rem; }

.prose-page { max-width: calc(var(--measure) + 6rem); }

.prose { font-family: var(--font-serif); font-size: 1.075rem; line-height: 1.78; color: var(--ink); }
.prose > * { max-width: var(--measure); }
.prose p { margin: 0 0 1.15em; }
.prose h2 { font-size: 1.45rem; margin: 2.2em 0 .5em; }
.prose h3 { font-size: 1.2rem; margin: 1.8em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .4em; }
.prose blockquote {
  margin: 1.5em 0; padding: .1em 0 .1em 1.2em; border-left: 2px solid var(--rule);
  color: var(--ink-soft); font-style: italic;
}
.prose img, .prose figure, .prose .embed-frame { max-width: 100%; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
.prose code {
  font-family: var(--font-mono); font-size: .87em; background: var(--tint);
  padding: .12em .35em; border-radius: 3px;
}
.prose pre {
  background: var(--tint); border: 1px solid var(--rule-soft); border-radius: var(--radius);
  padding: 1rem; overflow-x: auto; max-width: 100%; font-size: .86rem; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--rule); padding: .5em .7em; text-align: left; }

/* Chinese prose reads better slightly looser and without italic fallback. */
html[lang^="zh"] .prose { line-height: 1.95; letter-spacing: .01em; }
html[lang^="zh"] .prose blockquote { font-style: normal; }

.tag-row { margin: .8rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
  font-size: .72rem; color: var(--ink-soft); background: var(--tint);
  padding: .16rem .5rem; border-radius: 999px;
}

.post-foot { margin-top: 3.5rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.back-link { font-size: .875rem; }

/* --- home ----------------------------------------------------------------- */

.hero { padding-bottom: .5rem; }
.hero-title { font-size: clamp(2rem, 1.2rem + 3.2vw, 3.1rem); margin-bottom: .3rem; }
.hero-sub { color: var(--ink-soft); font-size: 1.08rem; margin: 0 0 1.6rem; max-width: var(--measure); }
.hero-bio { max-width: var(--measure); }

.section { margin-top: 2.8rem; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--rule); padding-bottom: .5rem; margin-bottom: 1.4rem;
}
.section-head h2 { font-size: 1.15rem; margin: 0; }
.section-more { font-size: .82rem; color: var(--ink-faint); }

/* --- post list ------------------------------------------------------------ */

.post-list { list-style: none; margin: 0; padding: 0; }
.post-card { border-bottom: 1px solid var(--rule-soft); }
.post-card:last-child { border-bottom: 0; }
.post-card-link { display: block; padding: 1.15rem 0; color: inherit; }
.post-card-link:hover { text-decoration: none; }
.post-card-link:hover .post-card-title { color: var(--accent); }
.post-card-date { display: block; font-size: .76rem; color: var(--ink-faint); letter-spacing: .04em; text-transform: uppercase; }
.post-card-title { font-size: 1.22rem; margin: .18rem 0 .3rem; transition: color .12s ease; }
.post-card-summary { margin: 0; color: var(--ink-soft); font-size: .935rem; max-width: 46rem; }

/* --- publications --------------------------------------------------------- */

.pub-list { list-style: none; margin: 0; padding: 0; }
.pub-year {
  font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint);
  letter-spacing: .12em; margin: 2.2rem 0 .8rem; padding-bottom: .35rem;
  border-bottom: 1px solid var(--rule);
}
.pub-list > .pub-year:first-child { margin-top: 0; }
.pub { padding: 1rem 0 1.3rem; }
.pub-title { font-size: 1.12rem; margin: 0 0 .3rem; }
.pub-authors { margin: 0 0 .15rem; font-size: .9rem; color: var(--ink-soft); }
.pub-venue { margin: 0 0 .6rem; font-size: .9rem; color: var(--ink-faint); }
.pub-abstract { margin: 0 0 .6rem; max-width: 46rem; }
.pub-abstract summary { cursor: pointer; font-size: .83rem; color: var(--accent); list-style: none; }
.pub-abstract summary::-webkit-details-marker { display: none; }
.pub-abstract summary::before { content: "▸ "; }
.pub-abstract[open] summary::before { content: "▾ "; }
.pub-abstract p {
  margin: .6rem 0 0; font-size: .92rem; color: var(--ink-soft); line-height: 1.7;
  border-left: 2px solid var(--rule); padding-left: .9rem;
}
.pub-links { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; }
.pub-links a {
  font-size: .78rem; border: 1px solid var(--rule); padding: .2rem .6rem;
  border-radius: 999px; color: var(--ink-soft);
}
.pub-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* --- fiction -------------------------------------------------------------- */

.novel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.6rem; }
.novel-card {
  display: grid; grid-template-columns: 116px 1fr; gap: 1.3rem; align-items: start;
  padding-bottom: 1.6rem; border-bottom: 1px solid var(--rule-soft);
}
.novel-card:last-child { border-bottom: 0; }
.novel-cover { display: block; border-radius: var(--radius); overflow: hidden; background: var(--tint); aspect-ratio: 2 / 3; }
.novel-cover img { width: 100%; height: 100%; object-fit: cover; }
.novel-cover-fallback {
  display: grid; place-items: center; width: 100%; height: 100%;
  font-family: var(--font-serif); font-size: 2.4rem; color: var(--ink-faint);
}
.novel-title { font-size: 1.3rem; margin: 0 0 .35rem; }
.novel-title a { color: inherit; }
.novel-title a:hover { color: var(--accent); text-decoration: none; }
.novel-meta { margin: 0 0 .55rem; font-size: .82rem; color: var(--ink-faint); }
.novel-blurb { margin: 0; color: var(--ink-soft); font-size: .95rem; max-width: 42rem; }
.novel-blurb-lg { font-size: 1.06rem; color: var(--ink-soft); }

.badge {
  font-size: .7rem; letter-spacing: .04em; padding: .13rem .5rem; border-radius: 999px;
  background: var(--tint); color: var(--ink-soft);
}
.badge-completed { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-ink); }

.novel-head { display: flex; gap: 1.4rem; align-items: flex-start; }
.novel-head-cover { width: 110px; border-radius: var(--radius); flex: none; }

/* chapter rail */
.with-rail { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; align-items: start; }
.rail-main { min-width: 0; }

.chapter-rail { position: sticky; top: 76px; }
.rail-toggle, .rail-handle { display: none; }
.rail-inner { border-right: 1px solid var(--rule); padding-right: 1.2rem; max-height: calc(100vh - 110px); overflow-y: auto; }
.rail-novel {
  display: block; font-family: var(--font-serif); font-size: 1rem; font-weight: 600;
  color: var(--ink); margin-bottom: .9rem;
}
.rail-novel:hover { color: var(--accent); text-decoration: none; }
.rail-list { list-style: none; margin: 0 0 1.2rem; padding: 0; counter-reset: none; }
.rail-list li { margin: 0; }
.rail-list a {
  display: grid; grid-template-columns: 1.6rem 1fr; gap: .4rem; align-items: baseline;
  padding: .3rem .5rem .3rem 0; font-size: .875rem; color: var(--ink-soft); border-radius: 4px;
}
.rail-list a:hover { color: var(--ink); text-decoration: none; }
.rail-num { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-faint); }
.rail-list .is-current a { color: var(--accent); font-weight: 600; }
.rail-list .is-current .rail-num { color: var(--accent); }
.rail-back { font-size: .8rem; color: var(--ink-faint); }

.toc-head { font-size: 1.05rem; margin: 2.8rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list a {
  display: grid; grid-template-columns: 2.2rem 1fr; gap: .5rem; align-items: baseline;
  padding: .55rem .4rem; border-radius: 4px; color: var(--ink);
}
.toc-list a:hover { background: var(--tint); text-decoration: none; }
.toc-num { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint); }

.fiction-prose p { text-indent: 0; }
html[lang^="zh"] .fiction-prose p { text-indent: 2em; }

.chapter-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: 3.5rem; padding-top: 1.4rem; border-top: 1px solid var(--rule);
}
.pager {
  display: flex; flex-direction: column; gap: .2rem; padding: .8rem 1rem;
  border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink);
}
.pager:hover { border-color: var(--accent); text-decoration: none; }
.pager span { font-size: .74rem; color: var(--ink-faint); letter-spacing: .04em; }
.pager strong { font-family: var(--font-serif); font-weight: 600; font-size: .95rem; }
.pager.next { text-align: right; }
.empty-pager { border: 0; }

@media (max-width: 860px) {
  .with-rail { grid-template-columns: 1fr; gap: 1.4rem; }
  .chapter-rail { position: static; }
  .rail-handle {
    display: inline-block; cursor: pointer; font-size: .85rem; color: var(--ink-soft);
    border: 1px solid var(--rule); border-radius: var(--radius); padding: .4rem .9rem;
  }
  .rail-handle::before { content: "☰ "; }
  .rail-inner { display: none; border-right: 0; padding: 1rem 0 0; max-height: none; }
  .rail-toggle:checked ~ .rail-inner { display: block; }
  .novel-card { grid-template-columns: 84px 1fr; gap: 1rem; }
  .chapter-pager { grid-template-columns: 1fr; }
  .pager.next { text-align: left; }
  .empty-pager { display: none; }
}

/* --- hobbies -------------------------------------------------------------- */

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.big-card a {
  display: block; height: 100%; padding: 1.6rem; border: 1px solid var(--rule);
  border-radius: var(--radius); color: inherit; background: var(--bg-raise);
}
.big-card a:hover { border-color: var(--accent); text-decoration: none; }
.big-card h2 { font-size: 1.25rem; margin-bottom: .4rem; }
.big-card p { color: var(--ink-soft); font-size: .93rem; margin: 0 0 1rem; }
.card-cta { font-size: .82rem; color: var(--accent); }

.art-grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 1.6rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}
.art-item figure { margin: 0; }
.art-item img { width: 100%; border-radius: var(--radius); background: var(--tint); }
.art-item figcaption { display: flex; flex-direction: column; gap: .12rem; margin-top: .6rem; font-size: .86rem; }
.art-meta { color: var(--ink-faint); font-size: .8rem; }
.art-note { color: var(--ink-soft); font-size: .82rem; }

.music-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem; }
.music-item { padding-bottom: 2rem; border-bottom: 1px solid var(--rule-soft); }
.music-item:last-child { border-bottom: 0; }
.music-head { display: flex; gap: 1.1rem; align-items: flex-start; margin-bottom: .9rem; }
.music-cover { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius); flex: none; background: var(--tint); }
.music-title { font-size: 1.15rem; margin: 0 0 .2rem; }
.music-meta { margin: 0; font-size: .82rem; color: var(--ink-faint); }
.music-note { margin: .45rem 0 0; font-size: .9rem; color: var(--ink-soft); max-width: 40rem; }
.music-item audio { width: 100%; max-width: 34rem; }
.embed-frame { position: relative; aspect-ratio: 16 / 9; max-width: 40rem; }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

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

.site-footer { border-top: 1px solid var(--rule); margin-top: auto; padding: 2.2rem 0; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.footer-title { font-family: var(--font-serif); font-weight: 600; margin: 0; font-size: .98rem; }
.footer-tagline { margin: 0; font-size: .84rem; color: var(--ink-faint); }
.footer-social { display: flex; gap: .9rem; margin-left: auto; }
.footer-social a { color: var(--ink-faint); line-height: 0; }
.footer-social a:hover { color: var(--accent); }
.footer-legal { flex-basis: 100%; margin: 0; font-size: .76rem; color: var(--ink-faint); }

/* --- language gate (root index) ------------------------------------------- */

.gate { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 2rem; }
.gate h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem); margin-bottom: .3rem; }
.gate p { color: var(--ink-soft); margin: 0 0 2rem; }
.gate-links { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.gate-links a {
  border: 1px solid var(--rule); border-radius: var(--radius); padding: .7rem 1.6rem;
  color: var(--ink); font-size: .95rem; min-width: 9rem;
}
.gate-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* volume grouping + fiction typography */
.rail-volume {
  margin: 1.1rem 0 .3rem; font-size: .74rem; letter-spacing: .06em;
  color: var(--ink-faint); text-transform: none;
}
.rail-inner > .rail-volume:first-of-type { margin-top: .4rem; }
.toc-volume {
  margin: 1.6rem 0 .35rem; font-family: var(--font-serif); font-size: .95rem;
  color: var(--ink-soft);
}
.toc-list + .toc-volume { margin-top: 1.8rem; }
.novel-series { margin: 0 0 .25rem; font-size: .8rem; color: var(--ink-faint); letter-spacing: .02em; }
.novel-subtle { margin: .5rem 0 0; font-size: .82rem; color: var(--ink-faint); }
.lang-tag {
  font-size: .72rem; border: 1px solid var(--rule); border-radius: 999px;
  padding: .05rem .45rem; color: var(--ink-faint);
}
.scene-break {
  text-align: center; margin: 2em 0; color: var(--ink-faint);
  letter-spacing: .6em; text-indent: 0 !important;
}
.fiction-prose blockquote {
  font-style: normal; background: var(--tint); border-left-color: var(--accent);
  padding: .9em 1.1em; border-radius: 0 var(--radius) var(--radius) 0;
}
.fiction-prose blockquote p { text-indent: 0; margin-bottom: .5em; }
.fiction-prose blockquote p:last-child { margin-bottom: 0; }
