:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f4f1ea;
  --ink: #20231f;
  --muted: #666d67;
  --faint: #8a918b;
  --line: #dedbd1;
  --line-strong: #c9c4b8;
  --accent: #336f68;
  --accent-soft: #e6f0ed;
  --amber: #b0722c;
  --shadow: 0 18px 44px rgba(30, 36, 32, 0.08);
  --sidebar-collapsed: 72px;
  --sidebar-expanded: 236px;
  --content-offset: calc(var(--sidebar-expanded) + clamp(32px, 6vw, 96px));
  --content-gutter: clamp(24px, 5vw, 80px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a17;
  --surface: #20241f;
  --surface-soft: #292e28;
  --ink: #f3f1ea;
  --muted: #b7beb6;
  --faint: #8f988f;
  --line: #3b423b;
  --line-strong: #596157;
  --accent: #9cc9bd;
  --accent-soft: rgba(156, 201, 189, 0.13);
  --amber: #e1b36e;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(222, 219, 209, 0.32) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
}

[data-theme="dark"] body {
  background:
    linear-gradient(90deg, rgba(89, 97, 87, 0.22) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
}

body.is-locked {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(51, 111, 104, 0.28);
  outline-offset: 3px;
}

svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.menu-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
  display: none;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-collapsed);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 12px;
  overflow: hidden;
  color: #f8fbf8;
  background: #1f2724;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: width 220ms ease, box-shadow 220ms ease;
}

.sidebar:hover,
.sidebar:focus-within,
.sidebar.is-open {
  width: var(--sidebar-expanded);
  box-shadow: 18px 0 44px rgba(30, 36, 32, 0.2);
}

.sidebar__brand {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  padding: 0 2px;
}

.sidebar__brand span {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  color: #1f2724;
  background: #f5eee0;
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.sidebar__brand::after {
  content: "Jichun Xiang";
  min-width: 140px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 760;
}

.sidebar__brand::after,
.nav-link span,
.sidebar__note {
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.sidebar:hover .sidebar__brand::after,
.sidebar:focus-within .sidebar__brand::after,
.sidebar.is-open .sidebar__brand::after,
.sidebar:hover .nav-link span,
.sidebar:focus-within .nav-link span,
.sidebar.is-open .nav-link span,
.sidebar:hover .sidebar__note,
.sidebar:focus-within .sidebar__note,
.sidebar.is-open .sidebar__note {
  opacity: 1;
  visibility: visible;
}

.sidebar__nav {
  display: grid;
  width: 100%;
  gap: 6px;
}

.nav-link {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  gap: 14px;
  padding: 0 13px;
  color: rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  transition: color 160ms ease, background 160ms ease;
}

.nav-link--child {
  color: rgba(255, 255, 255, 0.54);
}

.sidebar:hover .nav-link--child,
.sidebar:focus-within .nav-link--child,
.sidebar.is-open .nav-link--child {
  padding-left: 25px;
}

.sidebar:hover .nav-link--child::before,
.sidebar:focus-within .nav-link--child::before,
.sidebar.is-open .nav-link--child::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.nav-link:hover,
.nav-link.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-link span {
  min-width: 0;
  white-space: nowrap;
  font-size: 0.93rem;
  font-weight: 720;
}

.nav-link--soon span::after {
  content: "soon";
  margin-left: 8px;
  color: #ead5a4;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-toggle {
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 0 13px;
  color: rgba(255, 255, 255, 0.62);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: color 160ms ease, background 160ms ease;
}

.theme-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle span {
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 720;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.sidebar:hover .theme-toggle span,
.sidebar:focus-within .theme-toggle span,
.sidebar.is-open .theme-toggle span {
  opacity: 1;
  visibility: visible;
}

.sidebar__note {
  min-width: 184px;
  margin: auto 8px 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.78rem;
  line-height: 1.5;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(31, 39, 36, 0.38);
}

.page-shell {
  width: min(1060px, calc(100% - var(--content-offset) - var(--content-gutter)));
  margin-left: var(--content-offset);
  padding: 72px 0 56px;
}

.section {
  scroll-margin-top: 28px;
  padding: 52px 0;
  border-top: 1px solid var(--line);
}

.nested-section,
.misc-grid article {
  scroll-margin-top: 28px;
}

.profile-hero {
  min-height: 82svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 300px);
  gap: clamp(38px, 7vw, 82px);
  align-items: center;
  padding-top: 44px;
  border-top: 0;
}

.page-hero {
  min-height: 48svh;
  display: grid;
  align-content: end;
  max-width: 850px;
  padding-top: 84px;
  border-top: 0;
}

.page-hero h1 {
  max-width: 9ch;
}

.page-hero--wide h1 {
  max-width: 13ch;
  font-size: clamp(3.15rem, 7.2vw, 6.2rem);
}

.profile-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(4rem, 10vw, 7.8rem);
  line-height: 0.9;
}

h2 {
  margin-bottom: 18px;
  font-size: clamp(1.95rem, 4vw, 3.35rem);
  line-height: 1.04;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  line-height: 1.35;
}

p {
  color: var(--muted);
  line-height: 1.75;
}

.lead {
  max-width: 650px;
  font-size: clamp(1.08rem, 2vw, 1.32rem);
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.contact-row a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 8px 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(51, 111, 104, 0.16);
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 760;
}

.portrait-card {
  width: min(100%, 300px);
  margin: 0;
  justify-self: end;
}

.portrait-placeholder {
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  background:
    linear-gradient(160deg, rgba(51, 111, 104, 0.18), rgba(176, 114, 44, 0.14)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.portrait-placeholder span {
  display: grid;
  width: 118px;
  height: 118px;
  place-items: center;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  font-weight: 800;
}

figcaption {
  margin-top: 12px;
  color: var(--faint);
  font-size: 0.85rem;
  text-align: center;
}

.section-header {
  max-width: 800px;
  margin-bottom: 28px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
}

.two-column p {
  margin-bottom: 0;
}

.about-section .two-column {
  margin-bottom: 44px;
}

.about-stack {
  display: grid;
  gap: 42px;
}

.nested-section {
  padding-top: 38px;
  border-top: 1px solid var(--line);
}

.nested-section .section-header {
  margin-bottom: 20px;
}

.timeline,
.entry-list {
  display: grid;
  gap: 14px;
}

.timeline-item,
.entry {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 24px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.timeline-item:first-child,
.entry:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline-date {
  color: var(--amber);
  font-size: 0.88rem;
  font-weight: 820;
}

.timeline-item p,
.entry p,
.topic-grid p,
.misc-grid p,
.coming-soon p {
  margin-bottom: 0;
}

.topic-grid,
.misc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.topic-grid article,
.misc-grid article,
.coming-soon {
  padding: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(30, 36, 32, 0.04);
}

.blog-tools {
  display: grid;
  gap: 20px;
  margin-bottom: 34px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(30, 36, 32, 0.04);
}

[data-theme="dark"] .blog-tools,
[data-theme="dark"] .topic-grid article,
[data-theme="dark"] .misc-grid article,
[data-theme="dark"] .coming-soon,
[data-theme="dark"] .featured-card,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .media-block {
  background: rgba(32, 36, 31, 0.86);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.search-row input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.search-row input:focus-visible {
  outline: 3px solid rgba(51, 111, 104, 0.26);
  outline-offset: 2px;
}

.search-row button,
.reset-button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--surface);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 780;
  cursor: pointer;
}

.reset-button {
  color: var(--accent);
  background: transparent;
  border-color: var(--line);
}

.filter-groups {
  display: grid;
  gap: 12px;
}

.filter-line {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px 20px;
  align-items: start;
}

.filter-line > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-label {
  display: inline-flex;
  min-height: 30px;
  min-width: 74px;
  align-items: center;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-chip,
.meta-chip,
.page-link {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(51, 111, 104, 0.16);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.filter-chip.is-active,
.page-link.is-active {
  color: var(--surface);
  background: var(--accent);
}

.blog-status {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  color: var(--faint);
  font-size: 0.9rem;
  font-weight: 760;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 42px;
}

.featured-card,
.empty-state,
.media-block {
  padding: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(30, 36, 32, 0.04);
}

.post-row {
  display: grid;
  gap: 12px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.post-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.post-card-link {
  display: grid;
  gap: 8px;
}

.post-card-link h3,
.featured-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.12;
}

.post-card-link p {
  margin: 0;
}

.post-date,
.post-meta,
.muted-note {
  color: var(--faint);
  font-size: 0.83rem;
  font-weight: 760;
}

.post-tags,
.post-byline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.post-byline {
  margin: 24px 0 32px;
  color: var(--faint);
  font-size: 0.92rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.text-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.post-page {
  max-width: 820px;
  border-top: 0;
}

.post-page h1 {
  max-width: 15ch;
  font-size: clamp(2.35rem, 5.8vw, 4.8rem);
  line-height: 1;
}

.post-content {
  display: grid;
  gap: 18px;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.78;
}

.post-content h2 {
  margin-top: 16px;
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
}

.post-content p,
.post-content ul {
  margin: 0;
}

.post-content li + li {
  margin-top: 8px;
}

.post-content pre {
  overflow-x: auto;
  margin: 4px 0;
  padding: 18px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.post-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.math {
  color: var(--accent);
  font-weight: 760;
}

.media-block {
  display: grid;
  gap: 10px;
  margin-bottom: 30px;
}

.media-block a {
  color: var(--accent);
  font-weight: 800;
}

.media-block img,
.media-block video,
.media-block audio {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
}

.music-list {
  display: grid;
  gap: 14px;
}

.music-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.music-row:first-child {
  border-top: 0;
}

.music-row h3 {
  margin-top: 12px;
}

.entry {
  align-items: start;
  grid-template-columns: minmax(0, 1fr) auto;
}

.tag,
.card-kicker {
  display: inline-flex;
  width: max-content;
  align-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(51, 111, 104, 0.16);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 830;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag {
  padding: 6px 10px;
}

.card-kicker {
  margin-bottom: 18px;
  padding: 5px 9px;
}

.coming-soon {
  display: block;
}

.coming-soon h2 {
  max-width: 700px;
}

.site-footer {
  display: flex;
  width: min(1060px, calc(100% - var(--content-offset) - var(--content-gutter)));
  justify-content: space-between;
  gap: 18px;
  margin-left: var(--content-offset);
  padding: 26px 0 44px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent);
  font-weight: 780;
}

@media (max-width: 980px) {
  .page-shell,
  .site-footer {
    width: min(860px, calc(100% - var(--content-offset) - 32px));
  }

  .profile-hero,
  .two-column,
  .topic-grid,
  .misc-grid,
  .featured-grid {
    grid-template-columns: 1fr;
  }

  .portrait-card {
    justify-self: start;
  }
}

@media (max-width: 720px) {
  body {
    background-size: 36px 36px;
  }

  .menu-toggle {
    display: grid;
  }

  .sidebar {
    width: min(82vw, 288px);
    transform: translateX(-105%);
    transition: transform 220ms ease, box-shadow 220ms ease;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: min(82vw, 288px);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 18px 0 44px rgba(30, 36, 32, 0.26);
  }

  .page-shell,
  .site-footer {
    width: calc(100% - 36px);
    margin-left: 18px;
  }

  .page-shell {
    padding-top: 86px;
  }

  .section {
    scroll-margin-top: 80px;
    padding: 42px 0;
  }

  .nested-section,
  .misc-grid article {
    scroll-margin-top: 80px;
  }

  .profile-hero {
    min-height: auto;
    padding-top: 20px;
  }

  .page-hero {
    min-height: 42svh;
    padding-top: 20px;
  }

  h1 {
    font-size: clamp(3.35rem, 19vw, 5rem);
  }

  .page-hero--wide h1 {
    max-width: 100%;
    font-size: clamp(2.85rem, 15vw, 4.25rem);
  }

  .lead {
    font-size: 1.05rem;
  }

  .contact-row a {
    width: 100%;
  }

  .timeline-item,
  .entry,
  .search-row,
  .music-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .entry {
    gap: 14px;
  }

  .tag {
    justify-self: start;
  }

  .blog-status,
  .filter-line {
    align-items: flex-start;
  }

  .blog-status {
    flex-direction: column;
  }

  .filter-line {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-label {
    min-height: auto;
    min-width: 0;
  }

  .post-page h1 {
    max-width: 100%;
    font-size: clamp(2.05rem, 10.5vw, 3.35rem);
    line-height: 1.04;
  }

  .site-footer {
    flex-direction: column;
  }
}
