:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --text: #111111;
  --muted: #60605b;
  --line: #d8d8d1;
  --accent: #252525;
  --hot: #95ff66;
  --code-bg: #10110f;
  --code-text: #e7ffe0;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070807;
  --surface: #101110;
  --surface-2: #171916;
  --text: #f5f5f0;
  --muted: #a4a69e;
  --line: #2b2e29;
  --accent: #ffffff;
  --hot: #9dff6d;
  --code-bg: #000000;
  --code-text: #dfffda;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(127, 255, 91, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(127, 255, 91, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  line-height: 1.65;
}

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

button,
input {
  font: inherit;
}

.site-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.2;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.nav a,
.filter-row button,
.category-menu button {
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  padding: 8px 10px;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
}

.nav a:hover,
.nav a.active,
.filter-row button.active,
.category-menu button.active,
.category-menu button:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.menu-toggle {
  display: none;
}

main {
  min-height: calc(100vh - 76px);
}

.view {
  display: none;
  padding: 64px 0 80px;
}

.view.active {
  display: block;
}

.hero-view.active {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 42px;
  align-items: end;
  min-height: calc(100vh - 92px);
  padding-top: 72px;
}

.hero-copy h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(48px, 8vw, 106px);
  line-height: 0.96;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.lead {
  max-width: 720px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 20px;
}

.lead.small {
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.primary-link,
.ghost-link,
.contact-mail,
.back-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 9px 14px;
  border: 1px solid var(--accent);
}

.primary-link {
  background: var(--accent);
  color: var(--bg);
}

.ghost-link,
.back-button {
  background: transparent;
  color: var(--text);
}

.latest-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.panel-head a {
  color: var(--text);
}

.stack-list {
  display: grid;
}

.mini-post {
  display: grid;
  gap: 5px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.mini-post:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.mini-post strong {
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.section-head {
  margin-bottom: 24px;
}

.section-head h2,
.narrow h2 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 12px;
}

.search-box span {
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.filter-row button,
.category-menu button {
  background: transparent;
  cursor: pointer;
}

.post-grid,
.book-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.post-card,
.share-card,
.book-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 220px;
  padding: 18px;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card h3,
.share-card h3,
.book-card h3 {
  margin: 0;
  line-height: 1.25;
  font-size: 22px;
}

.post-card p,
.share-card p,
.book-card p {
  margin: 0;
  color: var(--muted);
}

.post-card footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

.pinned {
  border-color: color-mix(in srgb, var(--hot) 52%, var(--line));
}

.category-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.category-menu {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 8px;
}

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

.share-card {
  min-height: 0;
}

.share-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.copy-code {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

.narrow {
  max-width: 860px;
  margin: 0 auto;
}

.profile-block {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.profile-block img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.profile-block h3 {
  margin: 0 0 10px;
  font-size: 28px;
}

.profile-block p {
  color: var(--muted);
}

.photo-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 14px;
}

.photo-grid figure {
  margin: 0;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--text) 12%, transparent), transparent),
    var(--surface);
  overflow: hidden;
}

.photo-grid span {
  display: block;
  min-height: 260px;
  background:
    repeating-linear-gradient(90deg, transparent 0 16px, color-mix(in srgb, var(--text) 9%, transparent) 16px 17px),
    radial-gradient(circle at 70% 30%, color-mix(in srgb, var(--hot) 38%, transparent), transparent 22%),
    linear-gradient(145deg, color-mix(in srgb, var(--text) 18%, transparent), transparent 60%);
}

.photo-grid figcaption {
  padding: 14px;
  color: var(--muted);
}

.contact-mail {
  margin-top: 24px;
  background: var(--accent);
  color: var(--bg);
  font-size: 18px;
}

.article-view h1 {
  margin: 18px 0 14px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
}

.article-body {
  margin-top: 28px;
}

.article-body h2 {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.article-body p {
  color: var(--muted);
}

.toc {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.toc a {
  display: block;
  color: var(--muted);
  padding: 3px 0;
}

pre {
  overflow: auto;
  border-radius: var(--radius);
  padding: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  line-height: 1.55;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .menu-toggle {
    display: inline-grid;
    margin-left: auto;
    grid-column: 2;
    grid-row: 1;
  }

  .theme-toggle {
    grid-column: 3;
    grid-row: 1;
  }

  .nav {
    display: none;
    grid-column: 1 / -1;
    justify-content: stretch;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .nav.open {
    display: grid;
  }

  .nav a {
    text-align: center;
  }

  .hero-view.active,
  .category-layout,
  .profile-block,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .hero-view.active {
    min-height: auto;
  }

  .category-menu {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .post-grid,
  .book-shelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .site-shell {
    width: min(100% - 22px, 1180px);
  }

  .brand {
    min-width: 0;
  }

  .brand strong {
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .view {
    padding: 42px 0 58px;
  }

  .hero-copy h1 {
    font-size: 42px;
    line-height: 1.05;
    max-width: 100%;
  }

  .section-head {
    display: grid;
    align-items: start;
  }

  .post-grid,
  .book-shelf,
  .category-menu {
    grid-template-columns: 1fr;
  }

  .post-card,
  .share-card,
  .book-card {
    min-height: 0;
  }

  .profile-block img {
    width: 140px;
    height: 140px;
  }

  .photo-grid figure {
    min-height: 240px;
  }
}
