:root {
  --editorial-paper: #f4f1eb;
  --editorial-surface: #fffdfa;
  --editorial-ink: #252525;
  --editorial-muted: #5e5b56;
  --editorial-rule: #ded8ce;
  --editorial-accent: #8c3a29;
  --editorial-heading: Georgia, "Songti SC", "Noto Serif CJK SC", SimSun, serif;
}
[data-theme="dark"] {
  --editorial-paper: #181716;
  --editorial-surface: #221f1d;
  --editorial-ink: #f4efe8;
  --editorial-muted: #c2b9af;
  --editorial-rule: #4a423b;
  --editorial-accent: #ffad97;
}

#web_bg {
  background: var(--editorial-paper);
}
#page-header.full_page {
  height: clamp(320px, 55vh, 560px);
  background-attachment: scroll;
  background-position: center 48%;
}
#page-header.full_page #site-info {
  top: 45%;
  padding-inline: 24px;
}
#page-header #site-title,
#post-info .post-title {
  font-family: var(--editorial-heading);
  text-wrap: balance;
}
#page-header #site-title {
  font-size: clamp(2.5rem, 7vw, 5rem);
}
#page-header #scroll-down {
  display: none;
}

#recent-posts .recent-post-item,
#aside-content .card-widget,
.layout > #post {
  background: var(--editorial-surface);
  border: 1px solid var(--editorial-rule);
  border-radius: 12px;
  box-shadow: none;
}
#recent-posts .recent-post-item {
  min-height: 208px;
  height: auto;
}
#recent-posts .recent-post-item:hover,
#aside-content .card-widget:hover,
.layout > #post:hover {
  box-shadow: none;
}
#recent-posts .recent-post-item .post_cover {
  align-self: stretch;
  height: auto;
}
#recent-posts .recent-post-item .post_cover img {
  height: 100%;
  object-fit: cover;
}
#recent-posts .recent-post-item .recent-post-info {
  min-width: 0;
  padding: clamp(18px, 3vw, 34px);
}
#recent-posts .recent-post-item .article-title {
  color: var(--editorial-ink);
  font: 700 clamp(1.35rem, 2.5vw, 1.85rem)/1.35 var(--editorial-heading);
  overflow-wrap: anywhere;
}
#recent-posts .recent-post-item .article-title:hover {
  color: var(--editorial-accent);
}
#recent-posts .recent-post-item .article-meta-wrap,
#recent-posts .recent-post-item .article-meta-wrap a,
#recent-posts .recent-post-item .content {
  color: var(--editorial-muted);
}
#recent-posts .recent-post-item .content {
  margin-top: .65rem;
  font-size: .95rem;
  line-height: 1.7;
}

.layout > #post {
  min-width: 0;
  padding: clamp(20px, 4vw, 52px);
}
#article-container {
  max-width: 45rem;
  margin-inline: auto;
  color: var(--editorial-ink);
  font-size: clamp(1rem, .96rem + .2vw, 1.125rem);
  line-height: 1.85;
  overflow-wrap: anywhere;
}
#article-container h2,
#article-container h3 {
  margin-block: 1.8em .65em;
  color: var(--editorial-ink);
  font-family: var(--editorial-heading);
  line-height: 1.45;
}
#article-container h2 {
  padding-bottom: .35em;
  border-bottom: 1px solid var(--editorial-rule);
}
#article-container a:not(.headerlink) {
  color: var(--editorial-accent);
  text-decoration: underline;
  text-underline-offset: .18em;
}
#article-container pre,
#article-container .highlight,
#article-container .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
#article-container pre {
  overflow-wrap: normal;
}
#article-container img {
  max-width: 100%;
  height: auto;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

@media (max-width: 768px) {
  #recent-posts .recent-post-item .post_cover {
    height: clamp(145px, 42vw, 230px);
  }
  #recent-posts .recent-post-item .recent-post-info {
    padding: 18px 20px 22px;
  }
  #rightside #mobile-toc {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #recent-posts .recent-post-item,
  #recent-posts .recent-post-item img {
    transition: none;
  }
  #recent-posts .recent-post-item:hover img {
    transform: none;
  }
}

/* Transparent operator illustrations sit on the existing card surface. */
#recent-posts .recent-post-item .post_cover img:is(
  [src*="/curated/portrait-"],
  [data-lazy-src*="/curated/portrait-"]
) {
  object-fit: contain;
}


/* Cool lighting over the original castle artwork. */
#page-header.full_page::before {
  pointer-events: none;
  inset: 0;
  background: radial-gradient(ellipse at 50% 48%, #10202d18, #06131f80),
    linear-gradient(180deg, #07131c50, #07131c10 54%, #07131c8c);
}

#page-header.full_page #site-title {
  text-shadow: 0 3px 28px #06121ecc;
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  #recent-posts .recent-post-item {
    transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
  }

  #recent-posts .recent-post-item:is(:hover, :focus-within) {
    transform: translateY(-4px);
    border-color: #678696;
    box-shadow: 0 12px 28px #132a3b24;
  }

  #recent-posts .recent-post-item .post_cover img {
    transition: transform 360ms ease;
  }

  #recent-posts .recent-post-item:hover .post_cover img {
    transform: scale(1.035);
  }
}

@supports (animation-timeline: scroll(root block)) {
  @media (prefers-reduced-motion: no-preference) {
    body:has(#article-container.post-content)::after {
      content: "";
      position: fixed;
      inset: 0 0 auto;
      height: 3px;
      z-index: 101;
      pointer-events: none;
      background: linear-gradient(90deg, #365f78, #83c5cc);
      transform: scaleX(0);
      transform-origin: left;
      animation: editorial-reading-progress 1ms linear both;
      animation-timeline: scroll(root block);
    }
  }
}

@keyframes editorial-reading-progress {
  to {
    transform: scaleX(1);
  }
}

/* Homepage index and editorial sections */
#content-inner:has(> .editorial-home) {
  display: block;
  max-width: 1240px;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 44px);
}
.editorial-home {
  --home-surface: #111d24;
  --home-rule: #334a54;
  --home-text: #edf5f7;
  --home-muted: #afc2c9;
  --home-signal: #a1e0dc;
  display: grid;
  gap: clamp(28px, 5vw, 55px);
}
.home-section {
  min-width: 0;
}
.home-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--editorial-rule);
  margin-bottom: 14px;
  padding-bottom: 8px;
}
.home-section-head h2 {
  margin: 0;
  color: var(--editorial-ink);
  font-size: clamp(1.25rem, 2.3vw, 1.65rem);
  letter-spacing: .04em;
}
.home-text-link {
  color: var(--editorial-ink);
  font-size: .87rem;
  white-space: nowrap;
}
.home-text-link:hover {
  text-decoration: underline;
  text-underline-offset: .23em;
}
.home-collections,
.home-columns {
  display: grid;
  gap: 12px;
}
.home-collections {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.home-columns {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: clamp(18px, 4vw, 36px);
}
.home-collection,
.home-feature {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--home-rule);
  border-radius: 6px;
  background: var(--home-surface);
  color: var(--home-text);
}
.home-collection {
  display: flex;
  align-items: end;
  min-height: 180px;
  padding: 16px;
}
.home-collection img,
.home-collection::after,
.home-feature::after,
.home-feature img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.home-collection img,
.home-feature img {
  object-fit: cover;
  z-index: -2;
}
.home-collection::after {
  content: "";
  background: linear-gradient(0deg, #08141bf2, #08141b14 84%);
  z-index: -1;
}
.home-collection.portrait img {
  object-fit: contain;
  object-position: right center;
}
.home-collection.manga img {
  object-position: center 32%;
}
.home-collection-content {
  display: grid;
}
.home-collection-content strong {
  font-size: 1.14rem;
}
.home-collection-content span,
.home-feature-content time,
.home-feature-content p {
  color: var(--home-muted);
}
.home-arrow {
  margin-inline-start: auto;
  color: var(--home-signal);
}
.home-feature {
  display: flex;
  align-items: end;
  min-height: clamp(240px, 34vw, 360px);
  padding: clamp(20px, 4vw, 48px);
}
.home-feature::after {
  content: "";
  background: linear-gradient(90deg, #08141bf5 8%, #08141bb0 50%, #08141b29 100%);
  z-index: -1;
}
.home-feature h3 {
  margin: .2em 0;
  font-size: clamp(1.65rem, 4vw, 3rem);
  line-height: 1.2;
}
.home-feature p {
  max-width: 32em;
  margin: .6em 0 1em;
}
.home-feature time,
.home-index time {
  font-variant-numeric: tabular-nums;
}
.home-feature .home-text-link {
  color: var(--home-signal);
}
.home-index {
  margin: 0;
  padding: 0;
  list-style: none;
}
.home-index li + li {
  border-top: 1px solid var(--editorial-rule);
}
.home-index a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 9px 10px;
  color: var(--editorial-ink);
}
.home-index time {
  flex: none;
  color: var(--editorial-muted);
  font-size: .8rem;
}
.home-index a:is(:hover, :focus-visible) {
  background: var(--editorial-surface);
  text-decoration: underline;
}
.home-experiments {
  padding: 4px 14px;
  border: 1px solid var(--home-rule);
  border-radius: 6px;
  background: var(--home-surface);
}
.home-experiments li + li {
  border-color: var(--home-rule);
}
.home-experiments a {
  color: var(--home-text);
}
.home-experiments a:is(:hover, :focus-visible) {
  background: #1b3039;
}
.home-collection:hover,
.home-feature:hover {
  border-color: var(--home-signal);
  color: var(--home-text);
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .home-collection img,
  .home-feature img {
    transition: transform 420ms ease;
  }
  :is(.home-collection, .home-feature):hover img {
    transform: scale(1.035);
  }
}
@media (max-width: 700px) {
  .home-collections,
  .home-columns {
    grid-template-columns: minmax(0, 1fr);
  }
  .home-collection {
    min-height: 140px;
  }
}

.home-filter:not([hidden]) {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-block: 0 .55rem;
  color: var(--editorial-muted);
}
.home-filter select {
  padding: .35rem .55rem;
  border: 1px solid var(--editorial-rule);
  border-radius: 4px;
  background: var(--editorial-surface);
  color: var(--editorial-ink);
  font: inherit;
}
.home-index-category {
  display: block;
  color: var(--editorial-muted);
  line-height: 1.4;
}

/* Keep the landing page on a continuous dark canvas beneath the hero. */
body:has(.editorial-home) #web_bg {
  background: #0c151c !important;
}
#content-inner.layout:has(> .editorial-home) > .editorial-home {
  width: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  --editorial-ink: #e9f3f6;
  --editorial-muted: #b4c6ce;
  --editorial-rule: #32434e;
  --editorial-surface: #17252f;
}
body:has(.editorial-home) #page-header.full_page::before {
  background: linear-gradient(180deg, #06131f38, #06131f18 55%, #0c151c 100%);
}
.editorial-home .home-section-head h2,
.editorial-home .home-feature h3 {
  color: var(--home-text);
}
.editorial-home .home-collection::after {
  background: linear-gradient(0deg, #08141bfa, #08141b70 44%, #08141b00 78%);
}
.editorial-home .home-collection.portrait img {
  object-position: right top;
  max-height: 100%;
}
.editorial-home :is(.home-collection, .home-feature):focus-visible {
  outline: 2px solid var(--home-signal);
  outline-offset: 3px;
}
.editorial-home .home-collection:focus-visible .home-arrow,
.editorial-home .home-collection:hover .home-arrow {
  color: #e0fffc;
}

#body-wrap:has(.editorial-home) {
  background: #0c151c;
}
#body-wrap:has(.editorial-home) #page-header.nav-fixed #nav {
  background: #101c25ee;
}
#body-wrap:has(.editorial-home) #page-header.nav-fixed #nav :is(#site-name, .site-page, #toggle-menu) {
  color: #e9f3f6;
}

.home-scroll-rail {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-color: #46616d #111d24;
  padding-bottom: 6px;
}
.home-scroll-rail > a {
  scroll-snap-align: start;
}
.home-collections.home-scroll-rail {
  grid-template-columns: none;
  grid-auto-columns: calc((100% - 24px) / 3);
}
.home-feature-rail {
  grid-auto-columns: 85%;
}
@media (max-width: 700px) {
  .home-collections.home-scroll-rail,
  .home-feature-rail {
    grid-auto-columns: 86%;
  }
}
