:root {
  --bg: #0B1424;
  --bg-deep: #070E18;
  --surface: #121C2E;
  --surface-raised: #182338;
  --text-primary: #F4EDE3;
  --text-secondary: #C4CBD6;
  --text-muted: #8B97A8;
  --accent: #E8A35A;
  --accent-soft: #F0B46A;
  --mist: #9AA8BC;
  --border: rgba(244, 237, 227, 0.1);
  --font-display: "Fraunces", "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-sans: "Manrope", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --measure: 44rem;
  --header-h: 4.25rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background:
    radial-gradient(ellipse 70% 45% at 80% 0%, rgba(232, 163, 90, 0.08), transparent 55%),
    radial-gradient(ellipse 55% 40% at 0% 100%, rgba(26, 39, 64, 0.9), transparent 50%),
    var(--bg);
  line-height: 1.7;
}

a {
  color: var(--text-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-soft);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(11, 20, 36, 0.72);
  border-bottom: 1px solid var(--border);
}

.page-home .site-header {
  position: absolute;
  inset: 0 0 auto;
  background: linear-gradient(to bottom, rgba(7, 14, 24, 0.55), transparent);
  border-bottom: none;
  backdrop-filter: none;
}

.site-header__inner,
.site-footer__inner,
.site-main {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand__icon {
  display: block;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(244, 237, 227, 0.12), 0 0 18px rgba(232, 163, 90, 0.18);
}

.brand__text {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.brand__mark {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.brand__runtime {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.site-nav a:hover {
  color: var(--text-primary);
}

.site-nav__sep {
  color: rgba(244, 237, 227, 0.28);
  font-size: 0.85rem;
  user-select: none;
}

.site-main {
  padding: 2.5rem 0 4rem;
}

.site-main--home {
  padding-top: 2.5rem;
  scroll-margin-top: var(--header-h);
}

html:has(body.page-home) {
  scroll-behavior: smooth;
}

.page-home main {
  overflow-x: clip;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.page-home .site-footer {
  background: var(--bg-deep);
}

/* —— Home hero (blue hour) —— */
.hero-stage {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  color: var(--text-primary);
}

.hero-stage__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

.hero-stage__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
}

.hero-stage__img--portrait {
  display: none;
  object-position: center 62%;
}

.hero-stage__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 14, 24, 0.72) 0%, rgba(7, 14, 24, 0.28) 42%, rgba(7, 14, 24, 0.12) 100%),
    linear-gradient(180deg, rgba(7, 14, 24, 0.55) 0%, transparent 28%, rgba(7, 14, 24, 0.35) 70%, rgba(7, 14, 24, 0.88) 100%),
    radial-gradient(ellipse 42% 38% at 70% 45%, rgba(232, 163, 90, 0.14), transparent 72%);
  pointer-events: none;
}

.hero-stage__inner {
  position: relative;
  z-index: 2;
  width: min(1100px, calc(100% - 2rem));
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: stretch;
  padding: calc(var(--header-h) + 0.75rem) 0 1.25rem;
  animation: rise 1s ease both;
}

.hero-stage__content {
  position: relative;
  z-index: 2;
  width: 100%;
  align-self: center;
  margin: 0;
  padding: 0 0 1rem;
  animation: none;
}

.hero-stage__footer {
  position: static;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.hero-stage__brand {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: rgba(244, 237, 227, 0.72);
}

.hero-stage__headline {
  margin: 0;
  max-width: 22em;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.2vw, 3.4rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: 0.01em;
  text-shadow: 0 10px 40px rgba(7, 14, 24, 0.45);
}

.hero-stage__tagline {
  margin: 1.1rem 0 0;
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: rgba(244, 237, 227, 0.78);
  max-width: 28rem;
  line-height: 1.65;
  animation: rise 1.1s ease both;
  animation-delay: 0.12s;
}

.hero-stage__links {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1.5rem;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  color: rgba(244, 237, 227, 0.45);
  animation: rise 1.15s ease both;
  animation-delay: 0.18s;
}

.hero-stage__links a {
  color: rgba(244, 237, 227, 0.82);
  text-decoration: none;
  border-bottom: 1px solid rgba(232, 163, 90, 0.35);
  padding-bottom: 0.1rem;
}

.hero-stage__links a:hover {
  color: var(--accent-soft);
  border-color: var(--accent);
}

.hero-stage__scroll {
  position: static;
  left: auto;
  bottom: auto;
  z-index: 2;
  color: rgba(244, 237, 227, 0.78);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  animation: rise 1.2s ease both;
  animation-delay: 0.22s;
}

.hero-stage__scroll span {
  display: inline-block;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(244, 237, 227, 0.45);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.hero-stage__scroll:hover span {
  color: var(--accent-soft);
  border-color: var(--accent);
}

.hero-stage__meta {
  position: static;
  right: auto;
  bottom: auto;
  z-index: 2;
  display: grid;
  gap: 0.2rem;
  text-align: right;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(244, 237, 227, 0.55);
  font-variant-numeric: tabular-nums;
  animation: rise 1.2s ease both;
  animation-delay: 0.28s;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0;
}

.section-more {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.section-more:hover {
  color: var(--accent-soft);
}

.section {
  margin-top: 2.5rem;
  animation: rise 0.8s ease both;
}

.section h1,
.section h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.post-list {
  display: grid;
  gap: 1.25rem;
}

.post-item {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item time,
.post-item .meta,
.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.post-item h2 {
  margin: 0.25rem 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}

.post-item h2 a {
  text-decoration: none;
}

.tag {
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

.tag:hover {
  color: var(--accent-soft);
}

.article-header {
  margin-bottom: 2rem;
  max-width: var(--measure);
}

.article-header h1 {
  margin: 0.4rem 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.2;
  font-weight: 600;
}

.lede {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14rem;
  gap: 2rem;
  align-items: start;
}

.prose {
  max-width: var(--measure);
  color: var(--text-primary);
}

.prose :is(h2, h3, h4) {
  margin-top: 2rem;
  scroll-margin-top: 5rem;
  font-family: var(--font-display);
  font-weight: 600;
}

.prose p,
.prose li {
  color: var(--text-secondary);
}

.prose a {
  color: var(--accent-soft);
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
}

.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  width: 100%;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

.code-block {
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  overflow: hidden;
  background: var(--surface);
}

.code-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 0.3rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  font: inherit;
}

.copy-btn:hover {
  color: var(--text-primary);
  border-color: rgba(232, 163, 90, 0.45);
}

.highlight {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

.mermaid-block {
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  overflow-x: auto;
}

.mermaid-block pre.mermaid {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.mermaid-block svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.mermaid-block--error pre.mermaid {
  color: #f0a8a8;
}

.diagram-block {
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: rgba(18, 28, 46, 0.65);
  overflow-x: auto;
}

.diagram-block svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.diagram-block--d2 svg {
  min-width: min(100%, 18rem);
}

.toc {
  position: sticky;
  top: 5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: rgba(18, 28, 46, 0.75);
}

.toc__title {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.toc nav {
  display: grid;
  gap: 0.4rem;
}

.toc__item {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

.toc__item--h3 {
  padding-left: 0.75rem;
}

.toc__item.is-active {
  color: var(--accent-soft);
}

.reading-progress {
  margin-top: 1rem;
  height: 2px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.reading-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s linear;
}

.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  max-width: var(--measure);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  font-size: 0.75rem;
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 0.4rem;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #1A1208;
  border-color: transparent;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.05);
  color: #1A1208;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: rgba(232, 163, 90, 0.4);
  color: var(--text-primary);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-drift {
  from {
    transform: scale(1.02) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.06) translate3d(-1.2%, -0.6%, 0);
  }
}

@media (max-width: 720px) {
  .hero-stage__img--landscape {
    display: none;
  }

  .hero-stage__img--portrait {
    display: block;
    object-position: center 55%;
  }
}

@media (max-width: 860px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
    order: -1;
  }

  .hero-stage__inner {
    padding: calc(var(--header-h) + 0.5rem) 0 1rem;
  }

  .hero-stage__content {
    max-width: none;
  }

  .hero-stage__headline {
    font-size: clamp(1.85rem, 8vw, 2.6rem);
  }

  .hero-stage__meta {
    font-size: 0.65rem;
  }

  .photos-layout {
    grid-template-columns: 1fr;
  }

  .photos-rail {
    position: static;
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .photos-rail__list {
    display: flex;
    gap: 0.85rem;
    border: none;
    padding: 0;
  }

  .photos-rail__list li {
    grid-template-columns: auto;
    white-space: nowrap;
  }

  .photos-rail__count {
    display: none;
  }

  .photos-grid {
    columns: 2;
    column-gap: 0.75rem;
  }

  .photo-lightbox__shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .photo-lightbox__nav--prev,
  .photo-lightbox__nav--next {
    justify-self: center;
  }
}

/* —— Photos gallery —— */
.photos-page__intro h1 {
  margin-bottom: 0.35rem;
}

.photos-layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin-top: 2rem;
}

.photos-rail {
  position: sticky;
  top: 5.5rem;
}

.photos-rail__list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.85rem;
  border-left: 1px solid var(--border);
  display: grid;
  gap: 0.85rem;
}

.photos-rail__list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
}

.photos-rail__link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  position: relative;
}

.photos-rail__link::before {
  content: "";
  position: absolute;
  left: -0.95rem;
  top: 0.45rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 163, 90, 0.15);
}

.photos-rail__link:hover {
  color: var(--accent-soft);
}

.photos-rail__count {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.photos-month {
  margin-bottom: 2.5rem;
}

.photos-month__label {
  position: sticky;
  top: 4.6rem;
  z-index: 2;
  margin: 0 0 1rem;
  padding: 0.45rem 0;
  font-size: 1rem;
  color: var(--text-secondary);
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
}

.photos-grid {
  columns: 3;
  column-gap: 0.75rem;
}

.photos-thumb {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0;
  border: 0;
  background: var(--surface);
  border-radius: 0.35rem;
  overflow: hidden;
  cursor: pointer;
  break-inside: avoid;
  text-align: left;
  vertical-align: top;
}

.photos-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.45s ease;
}

.photos-thumb__meta {
  position: absolute;
  inset: auto 0 0;
  padding: 1.4rem 0.75rem 0.7rem;
  display: grid;
  gap: 0.15rem;
  color: #F4EDE3;
  background: linear-gradient(to top, rgba(7, 14, 24, 0.85), transparent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.photos-thumb__title {
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.photos-thumb__date {
  font-size: 0.75rem;
  color: rgba(244, 237, 227, 0.7);
}

.photos-thumb:hover img,
.photos-thumb:focus-visible img {
  transform: scale(1.04);
}

.photos-thumb:hover .photos-thumb__meta,
.photos-thumb:focus-visible .photos-thumb__meta {
  opacity: 1;
  transform: none;
}

.photo-lightbox {
  border: 0;
  padding: 0;
  max-width: none;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(16px);
  color: var(--text-primary);
}

.photo-lightbox::backdrop {
  background: rgba(5, 10, 18, 0.55);
}

.photo-lightbox__shell {
  position: relative;
  width: min(1100px, calc(100% - 2rem));
  height: min(90vh, 100%);
  margin: 5vh auto;
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  gap: 0.75rem;
  align-items: center;
}

.photo-lightbox__figure {
  margin: 0;
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.photo-lightbox__figure img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 0.35rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.photo-lightbox__caption {
  width: min(36rem, 100%);
  text-align: left;
}

.photo-lightbox__caption h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.photo-lightbox__line {
  margin: 0.2rem 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.photo-lightbox__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
}

.photo-lightbox__tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.photo-lightbox__close,
.photo-lightbox__nav {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(18, 28, 46, 0.8);
  color: var(--text-primary);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.photo-lightbox__close {
  position: absolute;
  top: -0.25rem;
  right: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  z-index: 2;
}

.photo-lightbox__nav {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.6rem;
  line-height: 1;
}

.photo-lightbox__close:hover,
.photo-lightbox__nav:hover {
  border-color: rgba(232, 163, 90, 0.45);
  color: var(--accent-soft);
}

@media (prefers-reduced-motion: reduce) {
  .hero-stage__content,
  .hero-stage__tagline,
  .hero-stage__scroll,
  .hero-stage__meta,
  .hero-stage__inner,
  .section,
  .photos-thumb img {
    animation: none !important;
    transition: none !important;
  }
}
