:root {
  --page-max: 1180px;
  --reading-max: 760px;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --space-1: .5rem;
  --space-2: .85rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3.5rem;
  --shadow: 0 18px 45px rgba(33, 35, 38, .08);
  font-size: 17px;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  transition: background-color .25s ease, color .25s ease;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .2em;
}

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

button,
input,
select { font: inherit; }

button,
.button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: .6rem;
  left: .6rem;
  padding: .7rem 1rem;
  transform: translateY(-180%);
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius-sm);
}

.skip-link:focus { transform: translateY(0); }

.site-shell {
  width: min(calc(100% - 2rem), var(--page-max));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
}

.nav-wrap {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
  font-family: Georgia, "Songti SC", serif;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: .1rem;
  margin-left: auto;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: .55rem .72rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
  font-size: .88rem;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}

.theme-toggle,
.menu-toggle {
  flex: 0 0 auto;
  padding: .55rem .85rem;
  color: var(--text);
  background: var(--surface);
}

.menu-toggle { display: none; }

main { min-height: 70vh; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: center;
  padding-block: clamp(4rem, 10vw, 8rem);
}

.eyebrow,
.content-type {
  margin: 0 0 .75rem;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  color: var(--heading);
  font-family: Georgia, "Songti SC", "STSong", serif;
  line-height: 1.25;
  text-wrap: balance;
}

h1 {
  margin: 0 0 1.2rem;
  font-size: clamp(2.6rem, 7vw, 5.8rem);
  letter-spacing: -.04em;
}

.page-hero h1 { font-size: clamp(2.3rem, 6vw, 4.5rem); }

h2 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
}

h3 { font-size: 1.2rem; }

.hero-copy {
  max-width: 760px;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--muted);
}

.status-line {
  margin-top: 1.5rem;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.hero-actions,
.card-actions,
.filter-row,
.meta,
.tags,
.pagination,
.back-row {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
}

.hero-actions { margin-top: 2rem; }

.bgm-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem .85rem;
  margin-top: 1rem;
}

.bgm-toggle {
  gap: .45rem;
}

.bgm-note {
  color: var(--muted);
  font-size: .78rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem 1.1rem;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  font-weight: 650;
}

.button.primary {
  color: var(--button-text);
  border-color: transparent;
  background: var(--accent);
}

.button:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.button.primary:hover { color: var(--button-text); background: var(--accent-strong); }

.button:disabled,
.button[aria-disabled="true"] {
  opacity: .58;
  cursor: not-allowed;
  transform: none;
}

.hero-orbit {
  position: relative;
  min-height: 330px;
  display: grid;
  place-items: center;
}

.stellar-banner-media { display: none; }

.portrait-placeholder {
  width: min(100%, 310px);
  aspect-ratio: 4 / 5;
  display: grid;
  align-content: end;
  padding: 1.3rem;
  overflow: hidden;
  color: var(--muted);
  background: var(--art-bg);
  border: 1px solid var(--border);
  border-radius: 48% 48% 20px 20px;
  box-shadow: var(--shadow);
}

.portrait-placeholder::before {
  content: "";
  width: 45%;
  aspect-ratio: 1;
  margin: 0 auto 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 34px color-mix(in srgb, var(--accent) 8%, transparent);
}

.portrait-placeholder span { text-align: center; font-size: .82rem; }

.section { padding-block: clamp(3rem, 8vw, 6rem); }

.section + .section { border-top: 1px solid var(--border); }

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

.section-heading p {
  max-width: 580px;
  margin: .4rem 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.content-card,
.category-card,
.project-card,
.idea-card,
.study-card {
  min-width: 0;
  padding: 1.35rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}

.content-card { grid-column: span 6; }
.category-card { grid-column: span 4; }
.project-card { grid-column: span 4; }
.idea-card { grid-column: span 6; }
.study-card { grid-column: span 4; }

.content-card h3,
.category-card h3,
.project-card h3,
.idea-card h3,
.study-card h3 { margin: .35rem 0 .55rem; }

.content-card h3 a,
.category-card h3 a,
.project-card h3 a {
  color: var(--heading);
  text-decoration: none;
}

.content-card p,
.category-card p,
.project-card p,
.idea-card p,
.study-card p { color: var(--muted); }

.meta {
  color: var(--muted);
  font-size: .82rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: .15rem .55rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .75rem;
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: -1.35rem -1.35rem 1.2rem;
  overflow: hidden;
  background: var(--art-bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.filter-panel {
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.filter-row label {
  display: grid;
  gap: .3rem;
  color: var(--muted);
  font-size: .78rem;
}

.filter-row input,
.filter-row select {
  min-height: 44px;
  max-width: 100%;
  padding: .55rem .75rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.filter-row input { width: min(320px, 100%); }

.filter-summary {
  margin: .8rem 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: .8rem;
}

.photo-tile {
  grid-column: span 4;
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.photo-tile.wide { grid-column: span 8; }

.photo-tile button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.photo-tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-tile.wide img { aspect-ratio: 2 / 1; }

.photo-tile figcaption {
  padding: .8rem 1rem;
  color: var(--muted);
  font-size: .83rem;
}

.lightbox[hidden] { display: none; }

.lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 7, 12, .9);
}

.lightbox-dialog {
  position: relative;
  width: min(100%, 1100px);
  max-height: 92vh;
}

.lightbox img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  width: 44px;
  padding: 0;
  color: white;
  background: rgba(0, 0, 0, .65);
  border-color: rgba(255, 255, 255, .35);
}

.page-hero { padding-block: clamp(3.5rem, 8vw, 6.5rem); }

.page-hero p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--reading-max)) minmax(220px, 1fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
  padding-block: 4rem 7rem;
}

.article-body {
  min-width: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 1.05rem;
}

.article-body h2,
.article-body h3 { margin-top: 2.4em; }
.article-body p { margin-block: 1.35em; }
.article-body blockquote {
  margin: 2rem 0;
  padding: .2rem 0 .2rem 1.2rem;
  color: var(--muted);
  border-left: 3px solid var(--accent);
}

.article-aside {
  position: sticky;
  top: 100px;
  padding: 1.2rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.article-aside h2 { font-size: 1.05rem; }

.status {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .6rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

.status::before {
  content: "●";
  color: var(--accent);
  font-size: .72rem;
}

.research-list {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  padding: 0;
  list-style: none;
}

.research-list li {
  padding: .65rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.archive {
  margin-top: 3rem;
  padding: 1.3rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.site-footer {
  padding-block: 2.5rem;
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: end;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
}

.footer-nav a { color: var(--muted); font-size: .85rem; }
.footer-note { margin: .4rem 0 0; color: var(--muted); }

.stellar-only { display: none; }
[data-theme="stellar"] .stellar-only { display: inline; }

@media (max-width: 900px) {
  .hero,
  .article-layout { grid-template-columns: 1fr; }
  .hero-orbit { min-height: 260px; }
  .portrait-placeholder { width: min(80%, 280px); aspect-ratio: 5 / 4; border-radius: var(--radius-lg); }
  .article-aside { position: static; }
  .category-card,
  .project-card,
  .study-card { grid-column: span 6; }
}

@media (max-width: 760px) {
  :root { font-size: 16px; }
  .site-shell { width: min(calc(100% - 1.25rem), var(--page-max)); }
  .nav-wrap { min-height: 64px; flex-wrap: wrap; padding-block: .5rem; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
  .site-nav {
    order: 4;
    display: none;
    width: 100%;
    margin: 0;
    padding: .35rem 0 .7rem;
    flex-direction: column;
    align-items: stretch;
  }
  .site-nav[data-open="true"] { display: flex; }
  .site-nav a { justify-content: center; }
  .theme-toggle { font-size: .82rem; }
  .hero { padding-block: 3rem 4.5rem; }
  h1 { font-size: clamp(2.45rem, 14vw, 4rem); }
  .hero-orbit { min-height: 220px; }
  .bgm-control { align-items: flex-start; flex-direction: column; }
  .content-card,
  .category-card,
  .project-card,
  .idea-card,
  .study-card,
  .photo-tile,
  .photo-tile.wide { grid-column: 1 / -1; }
  .photo-tile.wide img { aspect-ratio: 4 / 3; }
  .section-heading { align-items: start; flex-direction: column; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .filter-row label,
  .filter-row input,
  .filter-row select { width: 100%; }
  .footer-grid { grid-template-columns: 1fr; }
}
