:root {
  color-scheme: light;
  --paper: #fdfdfb;
  --ink: #262823;
  --muted: #74776d;
  --soft: #e7e8e0;
  --accent: #778360;
  --panel: #f1f2eb;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", "STSong", serif;
  --mono: "DM Mono", monospace;
  /* Reference scale: 16px below 768px, 20px from 768px. */
  --body: 1.25rem;
  --section-title: 1.75rem;
  --section-gap: 20rem;
  --chapter-art-size: 5.5rem;
  --chapter-art-gap: 1.5rem;
  --chapter-content-gap: 2rem;
  --hero: clamp(2.5rem, 3.5vw, 3.167rem);
  --small: 0.875rem;
  --reading-line: 1.4;
  --control-size: 44px;
  --control-inset: 16px;
  --control-top: 16px;
  --control-gap: 0.75rem;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #20221e;
  --ink: #e9e9df;
  --muted: #a5a99b;
  --soft: #3a3e33;
  --accent: #b0bc92;
  --panel: #2a2e25;
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: clamp(5rem, 8vw, 8rem);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--body);
  font-weight: 300;
  line-height: var(--reading-line);
  -webkit-font-smoothing: antialiased;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
}
button:disabled {
  cursor: default;
}
::selection {
  background: #dce3cf;
  color: #252821;
}
p,
h1,
h2,
h3 {
  margin: 0;
}
p {
  line-height: var(--reading-line);
  overflow-wrap: anywhere;
}
svg {
  display: block;
}
a,
button,
summary {
  touch-action: manipulation;
}
.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 10;
  padding: 1rem;
  background: var(--paper);
}
.skip-link:focus {
  top: 1rem;
}
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 5;
  pointer-events: none;
  height: clamp(5rem, 8vw, 7rem);
}
.site-header > * {
  pointer-events: auto;
}
.round-button {
  width: var(--control-size);
  height: var(--control-size);
  display: grid;
  place-items: center;
  border: 1px solid var(--soft);
  border-radius: 50%;
  background: var(--paper);
  box-shadow:
    0 2px 3px #171b1710,
    0 6px 20px #171b1708;
  transition:
    transform 0.2s,
    background 0.2s;
}
.round-button:hover {
  transform: translateY(-2px);
  background: var(--panel);
}
.home-link {
  position: absolute;
  top: var(--control-top);
  left: var(--control-inset);
}
.home-link svg {
  width: 90%;
  height: 90%;
}
.avatar-head { transform-origin: 32px 37px; }
.avatar-face { transform-origin: 32px 30px; }
.avatar-closed-eyes { stroke: var(--owl-eye-ink, currentColor); }
@media (prefers-reduced-motion: no-preference) {
  .avatar-head, .avatar-face, .avatar-eye {
    transition: transform 700ms cubic-bezier(.22, 1, .36, 1);
  }
  .site-header[data-reading="down"] { --gaze-y: 1; }
  .site-header[data-reading="up"] { --gaze-y: -1; }
  .site-header[data-reading] .avatar-head {
    transform: translateY(calc(.8px * var(--gaze-y))) rotate(calc(7deg * var(--gaze-y)));
  }
  .site-header[data-reading] .avatar-face {
    transform: translate(2px, calc(1.5px * var(--gaze-y))) scale(.94, .97);
  }
  .site-header[data-reading] .avatar-eye {
    transform: translate(1.2px, calc(1.5px * var(--gaze-y)));
    transition-duration: 320ms;
  }
}
[data-theme="dark"] .site-header:not([data-reading]) .avatar-head { transform: rotate(5deg); }
[data-theme="dark"] .avatar-eye { opacity: 0; }
[data-theme="dark"] .avatar-closed-eyes { opacity: 1; }
[data-theme="dark"] .site-header[data-reading] .avatar-eye { opacity: 1; }
[data-theme="dark"] .site-header[data-reading] .avatar-closed-eyes { opacity: 0; }
.menu-toggle {
  position: absolute;
  top: var(--control-top);
  right: calc(var(--control-inset) + var(--control-size) + var(--control-gap));
  font-family: var(--mono);
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  line-height: 1;
}
.menu-icon { width: 1.5rem; height: 1.5rem; }
.menu-line { transform-origin: 12px 12px; transition: transform 220ms ease; }
.menu-toggle[aria-expanded="true"] .menu-line-top { transform: rotate(45deg) translateY(4px); }
.menu-toggle[aria-expanded="true"] .menu-line-bottom { transform: rotate(-45deg) translateY(-4px); }
.navigation {
  position: absolute;
  top: calc(var(--control-top) + var(--control-size) + 12px);
  right: var(--control-inset);
  width: clamp(13rem, 20vw, 16rem);
  border: 1px solid var(--soft);
  padding: clamp(0.7rem, 1.4vw, 1rem);
  border-radius: 0.7rem;
  background: var(--paper);
  box-shadow: 0 12px 40px #00000010;
}
.navigation[hidden] {
  display: none;
}
.navigation a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem;
  border-radius: 0.3rem;
  font-size: clamp(0.88rem, 1vw, 0.98rem);
}
.navigation a:hover {
  background: var(--panel);
}
.navigation span {
  font: clamp(0.6rem, 0.7vw, 0.7rem) var(--mono);
  color: var(--muted);
}
main {
  width: 100%;
  max-width: 60rem;
  padding-inline: 1.5rem;
  margin: auto;
}
.intro {
  padding-top: calc(40vh + 2rem);
  padding-bottom: var(--section-gap);
}


h1 {
  font-size: var(--hero);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.name {
  position: relative;
  white-space: nowrap;
}
.name-mark {
  position: absolute;
  width: 100%;
  height: 0.23em;
  bottom: -0.075em;
  left: 0;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
}
.intro-bottom {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  margin-top: clamp(2rem, 4.5vw, 4.2rem);
  gap: 2rem;
}
.chapter {
  display: grid;
  grid-template-columns: 40% 60%;
  padding-bottom: var(--section-gap);
}
.chapter-heading {
  align-self: start;
  position: static;
}

h2 {
  max-width: 12em;
  padding-right: 1rem;
  text-wrap: balance;
  font-size: var(--section-title);
  font-weight: 400;
  line-height: var(--reading-line);
  letter-spacing: 0.03em;
}
.chapter-drawing {
  width: var(--chapter-art-size);
  height: var(--chapter-art-size);
  margin: 0 0 var(--chapter-art-gap);
  transform: rotate(-3deg);
}
.ink-drawing {
  color: var(--ink);
  overflow: visible;
}
.ink-drawing g {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.intro-aside {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
}
.lawn-drawing {
  width: clamp(7rem, 13vw, 11rem);
  height: auto;
}
.hero-heading {
  position: relative;
}
.owl-track {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: var(--hero);
  z-index: 1;
}
.owl-companion {
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75em;
  height: 1.75em;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: inherit;
  pointer-events: auto;
  z-index: 2;
}
.owl-companion svg { width: 100%; height: 100%; overflow: visible; }
/* Keep feather and face colors distinct instead of inverting the bird at night. */
[data-theme="dark"] .owl-companion,
[data-theme="dark"] .home-link svg {
  color: oklch(.46 .035 115);
  --owl-paper: oklch(.87 .025 95);
  --owl-eye-ink: oklch(.27 .02 115);
}
[data-theme="dark"] .owl-companion svg > g > path:first-child,
[data-theme="dark"] .home-link svg > g > path:first-child {
  stroke: oklch(.65 .035 115);
  stroke-width: 1.2;
}
.owl-companion .owl-eye,
.home-link svg ellipse { fill: var(--owl-eye-ink, currentColor); }
.owl-closed-eyes { stroke: var(--owl-eye-ink, currentColor); }

.owl-head { transform-origin: 32px 37px; }
.owl-face { transform-origin: 32px 30px; }
@media (prefers-reduced-motion: no-preference) {
  .owl-companion[data-sleeping="true"] .owl-eye,
  .owl-companion[data-sleeping="true"] .owl-head {
    transition: transform 420ms cubic-bezier(.25, 1, .5, 1);
  }
  .owl-companion[data-sleeping="true"] .owl-closed-eyes {
    transition: opacity 280ms ease-out;
  }
}

.owl-eye-left { transform-origin: 25.4px 29.7px; }
.owl-eye-right { transform-origin: 38.9px 29px; }
.chapter-content {
  min-width: 0;
}
.project-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
h3 {
  font-size: var(--body);
  font-weight: 400;
  line-height: var(--reading-line);
}
.project-title h3 {
  font-size: var(--body);
  letter-spacing: 0;
}
.status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--soft);
  border-radius: 2rem;
  padding: 0.25rem 0.55rem;
  font-size: var(--small);
  color: var(--muted);
}
.status > span {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: var(--accent);
}
.project-lead {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  color: var(--ink);
}
.project p:not(.project-lead),
.job > p,
.thoughts .chapter-content > p:last-child {
  color: var(--muted);
}
.project-details {
  margin-top: 1.25rem;
  border-bottom: 1px solid var(--soft);
}
summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
  padding: 1.1rem 0;
  font-size: var(--body);
}
summary::-webkit-details-marker {
  display: none;
}
summary:hover {
  color: var(--accent);
}
.details-open,
details[open] .details-closed {
  display: none;
}
details[open] .details-open {
  display: inline;
}
.detail-plus {
  font-family: var(--mono);
  font-size: 1.2rem;
}
details[open] .detail-plus {
  transform: rotate(45deg);
}
.detail-body {
  padding: 0.4rem 0 1.5rem;
  font-size: var(--body);
}
dl {
  margin: 1.5rem 0 0;
}
dl > div + div {
  margin-top: 1rem;
}
dt {
  font-weight: 500;
}
dd {
  margin: 0.3rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}
.project-note-heading { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.project-note h3 { color: var(--ink); margin: 0; }
.project-note {
  color: var(--muted);
  margin-top: clamp(2rem, 4vw, 3rem);
  font-size: var(--body);
  line-height: 1.5;
}
.job + .job {
  margin-top: 3rem;
}
.job-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}
.job time {
  font-family: var(--serif);
  font-size: var(--body);
  white-space: nowrap;
  color: var(--muted);
}
.job > p { margin-top: 1rem; }
.company-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .85rem; max-width: 100%; }
.company-kind { color: var(--muted); font-size: var(--small); font-weight: 300; line-height: 1.5; }
.project-loop { display: block; width: 50px; height: 26px; flex-shrink: 0; color: var(--ink); }
.thought-symbol {
  color: var(--accent);
  font-size: clamp(2rem, 3.8vw, 3.3rem);
  display: block;
  line-height: 1;
  margin-bottom: 1.8rem;
}
.thought-title {
  font-size: var(--body);
  font-weight: 400;
  line-height: var(--reading-line);
  margin-bottom: 0.25rem;
}
.contact {
  padding-bottom: clamp(6rem, 10vw, 9rem);
}
.contact-intro {
  font-size: var(--body);
  margin-bottom: 2rem;
}
.email-link {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: var(--body);
  line-height: 1.4;
}
.email-drawing {
  width: 1.5em;
  height: 1.5em;
  flex: 0 0 1.5em;
  transition: transform 200ms ease;
}
footer {
  padding: 1.7rem 0 2.5rem;
  border-top: 1px solid var(--soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: var(--small);
}
footer > span:last-child {
  transform: translateX(calc(-1 * var(--dock-avoidance, 0px)));
}
.theme-toggle {
  position: absolute;
  right: var(--control-inset);
  top: var(--control-top);
}
.theme-toggle svg {
  width: 1.3rem;
  height: 1.3rem;
}
.theme-toggle circle {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
}
.theme-toggle path {
  fill: var(--muted);
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Layout and type breakpoints are independent, matching the reference site. */
@media (min-width: 1200px) {
  .chapter-heading {
    position: sticky;
    top: 2rem;
    display: flex;
    flex-direction: column;
    gap: var(--chapter-art-gap);
  }
  .chapter-heading h2 { order: -1; }
  .chapter-heading .chapter-drawing { margin: 0; }
}
@media (min-width: 880px) and (max-width: 1199px) {
  main { max-width: 50rem; }
  .chapter { grid-template-columns: 30% 70%; }
  .chapter-heading { position: static; }
}
@media (max-width: 879px) {
  .chapter { grid-template-columns: minmax(0, 1fr); gap: var(--chapter-content-gap); }
  .chapter-heading { position: static; }
}
@media (max-width: 799px) {
  main { max-width: 40rem; }
}
@media (max-width: 767px) {
  :root {
    --control-top: 8px;
    --section-gap: 10rem;
    --body: 1rem;
    --section-title: 1.5rem;
    --small: 0.8125rem;
    --hero: clamp(1.5rem, 4.8vw, 2.25rem);
  }
  main { padding-inline: 2rem; }
  h2 { line-height: 1.1; }
  h3 { line-height: 1.5; }

  .intro-bottom { margin-top: 2rem; gap: 1rem; flex-wrap: wrap; }
  .intro-aside { width: 100%; justify-content: space-between; margin-top: 1rem; }
  .lawn-drawing { width: 8.5rem; }

  .project-title { gap: 0.75rem; }
  .email-link { font-size: var(--body); overflow-wrap: anywhere; }
  footer { align-items: flex-start; flex-wrap: wrap; padding-bottom: 5.5rem; }
  footer > span:last-child { margin-left: auto; white-space: nowrap; }
  .navigation a { min-height: 2.9rem; }
}
@media (max-width: 359px) {
  main { padding-inline: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}


/* The floating chapter rail opens upward without shifting page content. */
.section-dock {
  position: fixed;
  right: var(--control-inset);
  bottom: max(var(--control-inset), env(safe-area-inset-bottom));
  z-index: 7;
  width: var(--control-size);
  height: calc(220px + var(--control-size));
  pointer-events: none;
}
.section-dock[hidden] { display: none; }
.section-dock::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--soft);
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 94%, var(--soft));
  box-shadow: inset 1px 1px 2px var(--paper), 0 3px 5px #171b1715, 0 10px 28px #171b1710;
  transform-origin: bottom;
  transform: scaleY(0.17);
  opacity: 0;
  transition: transform 260ms cubic-bezier(.22,1,.36,1), opacity 160ms ease;
}
.section-dock[data-open="true"] { pointer-events: auto; }
.section-dock[data-open="true"]::before { transform: scaleY(1); opacity: 1; }
.dock-toggle { position: absolute; bottom: 0; right: 0; pointer-events: auto; }
.dock-toggle:hover { transform: none; }
.section-dock[data-open="true"] .dock-toggle { background: transparent; border-color: transparent; box-shadow: none; }
.dock-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .35; }
.dock-progress { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); transition: opacity 160ms ease; }
.dock-progress circle { fill: none; stroke: var(--muted); stroke-width: 1.25; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--reading-progress, 0)); }
.section-dock[data-open="true"] .dock-progress { opacity: 0; }
.dock-links { position: relative; visibility: hidden; opacity: 0; transform: translateY(12px); transition: opacity 180ms ease, transform 260ms cubic-bezier(.22,1,.36,1), visibility 180ms; }
.section-dock[data-open="true"] .dock-links { visibility: visible; opacity: 1; transform: translateY(0); }
.dock-links a { position: relative; display: grid; place-items: center; width: 100%; height: 44px; border-radius: 50%; }
.dock-links a::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; opacity: 0; background: var(--soft); box-shadow: inset 0 1px 3px #171b1718, 0 2px 3px #171b1710; transition: opacity 180ms ease; }
.dock-links a[aria-current="location"]::before { opacity: 1; }
.dock-links a[aria-current="location"] .dock-dot { opacity: .8; }
.dock-links .dock-dot { position: relative; }
.dock-label { position: absolute; right: calc(100% + 12px); padding: .35rem .65rem; border: 1px solid var(--soft); border-radius: .35rem; background: var(--paper); color: var(--ink); font-size: .8125rem; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 150ms ease; pointer-events: none; }
.dock-links a:hover .dock-label, .dock-links a:focus-visible .dock-label { opacity: 1; visibility: visible; }


/* Writing: quiet title/summary list and standalone reading page. */
.thought-entry + .thought-entry { margin-top: 48px; }
.thought-entry h3 { font-size: var(--body); font-weight: 400; line-height: 1.4; }
.thought-entry h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.thought-summary { display: block; }
.thought-summary p { color: var(--ink); }
.essay-back, .essay-theme { position: fixed; top: var(--control-top); width: var(--control-size); height: var(--control-size); z-index: 10; }
.essay-back { left: 16px; }
.essay-theme { right: 16px; }
.essay-back svg, .essay-theme svg { width: 20px; height: 20px; }
.essay-title-bar {
  position: fixed; inset: 0 0 auto; z-index: 9;
  min-height: calc(var(--control-top) + var(--control-size) + 12px);
  padding: var(--control-top) 76px 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); border-bottom: 1px solid var(--soft);
  color: var(--ink); opacity: 0; visibility: hidden; pointer-events: none;
}
.essay-title-bar.is-visible { opacity: 1; visibility: visible; }
.essay-title-bar span {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
  width: 100%; max-width: 640px; font-size: 16px; line-height: 22px;
}
@media (max-width: 767px) {
  .essay-title-bar span { font-size: 14px; line-height: 20px; }
}
main.essay-main { width: 100%; max-width: 960px; margin: 0 auto; padding: 160px 24px 48px; }
.essay-main article { max-width: 640px; margin: 0 auto; }
.essay-heading { margin-bottom: 48px; }
.essay-meta { display: flex; gap: 24px; font-size: 14px; line-height: 20px; color: var(--muted); margin-bottom: 16px; }
.essay-heading h1 { font-size: 48px; font-weight: 300; line-height: 1.3; letter-spacing: 0; overflow-wrap: anywhere; }
.essay-body { font-size: 18px; line-height: 1.7; overflow-wrap: anywhere; }
.essay-body p { line-height: inherit; margin: 0 0 16px; }
.essay-body h2, .essay-body h3 { max-width: none; padding-right: 0; text-wrap: wrap; scroll-margin-top: 80px; font-size: inherit; font-weight: 500; line-height: inherit; margin: 48px 0 24px; }
.essay-body strong { font-weight: 600; }
.essay-body ul, .essay-body ol { padding-left: 1.5em; margin: 0 0 24px; }
.essay-body li { margin-bottom: 8px; }
.essay-body img { display: block; max-width: 100%; height: auto; margin: 32px auto; }
.essay-image-open { display: block; width: fit-content; max-width: 100%; margin: 32px auto; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.essay-image-open img { margin: 0; }
.essay-image-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
html.image-viewer-open { overflow: hidden; }
.image-viewer { position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: clamp(0.75rem, 2.8vw, 2rem); border: 0; background: transparent; color: var(--ink); }
.image-viewer[open] { display: flex; align-items: center; justify-content: center; animation: image-preview-fade-in 160ms ease; }
.image-viewer::backdrop { background: rgba(15, 23, 42, 0.42); backdrop-filter: blur(1.5px); }
.image-preview-panel:focus { outline: none; }
.image-viewer .image-preview-panel {
  position: relative;
  width: fit-content;
  height: fit-content;
  max-width: min(94vw, 1360px);
  max-height: min(92vh, 980px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.4rem, 1.1vw, 0.85rem);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 94%, white 6%);
  border: 1px solid color-mix(in srgb, var(--soft) 68%, var(--paper) 32%);
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.45) inset;
  transform: translateY(4px) scale(0.985);
  opacity: 0;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.image-viewer[open] .image-preview-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.image-viewer .image-preview-content {
  display: block;
  width: auto;
  height: auto;
  max-width: min(88vw, 1280px);
  max-height: min(84vh, 900px);
  object-fit: contain;
  border-radius: 8px;
  background: var(--paper);
}

/* 横图/竖图/方图分开限制，避免留白比例不协调 */
.image-viewer .image-preview-panel[data-orientation="landscape"] .image-preview-content {
  max-width: min(90vw, 1360px);
  max-height: min(82vh, 860px);
}

.image-viewer .image-preview-panel[data-orientation="portrait"] .image-preview-content {
  max-width: min(60vw, 760px);
  max-height: min(88vh, 980px);
}

.image-viewer .image-preview-panel[data-orientation="square"] .image-preview-content {
  max-width: min(72vw, 900px);
  max-height: min(86vh, 920px);
}

/* 小图不被过度放大，保留适当留白 */
.image-viewer .image-preview-panel[data-small-image="true"] .image-preview-content {
  max-width: min(68vw, 760px);
  max-height: min(70vh, 700px);
}

@media (max-width: 800px) {
  .image-viewer {
    padding: clamp(0.5rem, 2.4vw, 1rem);
  }

  .image-viewer .image-preview-panel {
    max-width: 96vw;
    max-height: 92vh;
    border-radius: 10px;
    padding: 0.35rem;
  }

  .image-viewer .image-preview-content,
  .image-viewer .image-preview-panel[data-orientation="landscape"] .image-preview-content,
  .image-viewer .image-preview-panel[data-orientation="portrait"] .image-preview-content,
  .image-viewer .image-preview-panel[data-orientation="square"] .image-preview-content,
  .image-viewer .image-preview-panel[data-small-image="true"] .image-preview-content {
    max-width: calc(96vw - 0.7rem - 2px);
    max-height: 86vh;
  }
}

:root[data-theme="dark"] .image-viewer::backdrop {
  background: rgba(2, 6, 23, 0.62);
}

:root[data-theme="dark"] .image-viewer .image-preview-panel {
  background: color-mix(in srgb, var(--paper) 95%, #0f172a 5%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.48),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

:root[data-theme="dark"] .image-viewer .image-preview-content {
  background: color-mix(in srgb, var(--paper) 92%, #0f172a 8%);
}

@keyframes image-preview-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-viewer[open], .image-viewer .image-preview-panel { animation: none; transition: none; }
}
.essay-body blockquote { margin: 24px 0; border-left: 2px solid var(--soft); padding-left: 20px; color: var(--muted); }
.essay-body a { text-decoration: underline; text-underline-offset: 4px; }
.essay-body hr { border: 0; border-top: 1px solid var(--soft); margin: 40px 0; }
@media (max-width: 767px) {
  main.essay-main { max-width: 640px; padding: 160px 32px 48px; }
  .essay-heading h1 { font-size: 36px; }
  .essay-body { font-size: 16px; }
}
@media (max-width: 359px) { main.essay-main { padding-inline: 24px; } }

/* Frosted floating controls, matching the reference's translucent glass. */
:root {
  --glass-fill: rgb(187 187 188 / 12%);
  --glass-hover: rgb(187 187 188 / 22%);
  --glass-highlight: rgb(255 255 255 / 90%);
  --glass-edge: rgb(255 255 255 / 60%);
  --glass-shadow: inset 0 0 0 1px rgb(255 255 255 / 10%),
    inset 1.8px 3px 0 -2px var(--glass-highlight),
    inset -2px -2px 0 -2px var(--glass-edge),
    inset -0.3px -1px 4px rgb(0 0 0 / 12%),
    inset 0 3px 4px -2px rgb(0 0 0 / 20%),
    0 1px 5px rgb(0 0 0 / 10%), 0 8px 20px rgb(0 0 0 / 10%);
}
:root[data-theme="dark"] {
  --glass-fill: rgb(80 83 77 / 22%);
  --glass-hover: rgb(115 119 108 / 28%);
  --glass-highlight: rgb(255 255 255 / 28%);
  --glass-edge: rgb(255 255 255 / 12%);
}
.round-button,
.navigation,
.section-dock::before,
.dock-label {
  background: var(--glass-fill);
  border-color: transparent;
  -webkit-backdrop-filter: blur(8px) saturate(1.5);
  backdrop-filter: blur(8px) saturate(1.5);
  box-shadow: var(--glass-shadow);
}
.round-button:hover { background: var(--glass-hover); }
.section-dock[data-open="true"] .dock-toggle {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
@supports not ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) {
  .round-button, .navigation, .section-dock::before, .dock-label { background: var(--paper); }
}

/* Compact contact actions, with a dismissible WeChat card. */
.contact-links { display: flex; align-items: center; gap: 1rem; }
.contact-links .ink-drawing { color: inherit; }
.contact-links .email-link, .wechat-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 6px;
  color: var(--ink); background: none; border: 0; cursor: pointer;
  font: inherit; font-size: var(--body);
}
.contact-links :is(.email-link, .wechat-link):hover { color: var(--accent); }
.contact-links :is(.email-link, .wechat-link):hover .email-drawing {
  transform: translateY(-3px) rotate(-4deg);
}
.wechat-card {
  position: fixed; inset: auto; margin: 0;
  width: min(260px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 34px 16px 18px; overflow: auto;
  border: 1px solid var(--soft); border-radius: 18px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 8px 28px #0002;
}
.wechat-card::backdrop { background: transparent; }
.wechat-card img { display: block; width: 100%; height: auto; max-height: 65dvh; object-fit: contain; border-radius: 8px; }
.wechat-card p { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: var(--small); }

/* Article contents share the home node rail and reveal labels on hover/focus. */
.essay-dock {
  --essay-node-size: min(44px, calc((100dvh - 100px) / var(--essay-node-count, 1)));
  height: calc(var(--essay-node-count, 1) * var(--essay-node-size) + var(--control-size));
}
.essay-dock .dock-links a { height: var(--essay-node-size); }
.essay-dock .dock-label {
  width: max-content;
  max-width: min(360px, calc(100vw - 92px));
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

/* Hand-drawn sun/moon contours shared by home and reading pages. */
.theme-toggle svg, .essay-theme svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle svg path, .theme-toggle svg circle {
  fill: none; stroke: currentColor; stroke-width: 1.5;
}
.theme-toggle svg .theme-sketch, .essay-theme svg .theme-sketch {
  stroke-width: .75; opacity: .4;
}
.theme-toggle .theme-sun, .essay-theme .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-sun,
:root[data-theme="dark"] .essay-theme .theme-sun { display: block; }

/* Deliberate contours keep the small reclining figure readable. */

/* Reference-style reveal: a quick fade, followed by a slow, quiet settling. */
@keyframes content-enter {
  from { opacity: 0; translate: 0 48px; }
  45% { opacity: 1; }
  to { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .entrance-pending { opacity: 0; translate: 0 48px; }
  .entrance-playing {
    animation: content-enter 1.92s cubic-bezier(.22, 1, .36, 1) var(--entrance-delay, 0ms) both;
  }
}
@media print {
  .entrance-pending, .entrance-playing { opacity: 1 !important; translate: none !important; animation: none !important; }
}
