:root {
  --ink: #202326;
  --muted: #667079;
  --paper: #fbf8f0;
  --paper-soft: #f4efe4;
  --line: #ded6c8;
  --field: rgba(255, 253, 247, 0.88);
  --field-ink: #202326;
  --hero-text: #fff8ec;
  --hero-muted: #dfd6c9;
  --hero-kicker: #cfe4df;
  --night: #0d1824;
  --night-2: #172b3a;
  --lake: #3c8078;
  --ember: #a94732;
  --gold: #c99b54;
  --shadow: 0 22px 50px rgba(15, 24, 32, 0.18);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #ede6d8;
  --muted: #b8c2c7;
  --paper: #17222c;
  --paper-soft: #111b24;
  --line: rgba(213, 224, 222, 0.18);
  --field: rgba(8, 16, 23, 0.62);
  --field-ink: #f4eadb;
  --hero-text: #fff8ec;
  --hero-muted: #e7ddcd;
  --hero-kicker: #bde9df;
  --lake: #7fc6b9;
  --ember: #e28b76;
  --gold: #deb76e;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(201, 155, 84, 0.18), transparent 34rem),
    linear-gradient(180deg, #102134 0, #315865 21rem, var(--paper) 21rem, var(--paper-soft) 100%);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  font-size: 18px;
  line-height: 1.9;
  letter-spacing: 0;
}

a {
  color: #1e706b;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--ember);
}

.site-shell {
  min-height: 100vh;
}

body.wallpaper-active {
  background: transparent;
}

body.wallpaper-active .paper {
  background: rgba(251, 248, 240, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

:root[data-theme="dark"] body.wallpaper-active .paper {
  background: rgba(23, 34, 44, 0.82);
}

body.wallpaper-active .site-footer {
  background: transparent;
}

.site-hero {
  position: relative;
  overflow: hidden;
  color: #f7efe3;
  min-height: 430px;
  padding: 34px 24px 104px;
}

.site-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 75% 20%, rgba(238, 214, 161, 0.2), transparent 18rem),
    linear-gradient(120deg, rgba(13, 24, 36, 0.62), rgba(21, 43, 58, 0.38)),
    url("/assets/img/night-lake-hero.png") center 38% / cover no-repeat;
}

.site-hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 42px;
  background: linear-gradient(180deg, transparent, var(--paper));
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 66px;
}

.site-mark {
  color: var(--hero-text);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid rgba(247, 239, 227, 0.24);
  border-radius: 999px;
  color: var(--hero-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 36px;
  border: 1px solid rgba(247, 239, 227, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--hero-text);
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.theme-toggle:hover {
  border-color: rgba(247, 239, 227, 0.66);
  background: rgba(255, 255, 255, 0.14);
}

.nav-links a:hover {
  border-color: rgba(247, 239, 227, 0.58);
  background: rgba(255, 255, 255, 0.08);
}

.hero-kicker {
  margin: 0 0 10px;
  color: var(--hero-kicker);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-title {
  max-width: 760px;
  margin: 0;
  color: var(--hero-text);
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 800;
  line-height: 1.08;
}

.hero-description {
  max-width: 680px;
  margin: 22px 0 0;
  color: var(--hero-muted);
  font-size: 19px;
  line-height: 1.8;
}

.page-wrap {
  width: min(1080px, calc(100% - 36px));
  margin: -58px auto 0;
  padding-bottom: 64px;
  position: relative;
  z-index: 2;
}

.paper {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}

.content-panel,
.side-panel {
  padding: clamp(24px, 4vw, 44px);
}

.content-panel h1,
.content-panel h2,
.content-panel h3,
.post-content h1,
.post-content h2,
.post-content h3 {
  margin: 2.2em 0 0.75em;
  color: var(--ink);
  line-height: 1.35;
}

.content-panel h1:first-child,
.content-panel h2:first-child,
.post-content h1:first-child,
.post-content h2:first-child {
  margin-top: 0;
}

.content-panel h1,
.post-content h1 {
  font-size: 34px;
}

.content-panel h2,
.post-content h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 26px;
}

.content-panel h3,
.post-content h3 {
  font-size: 21px;
}

.content-panel p,
.post-content p {
  margin: 1.15em 0;
}

.content-panel ul,
.post-content ul {
  padding-left: 1.35em;
}

.content-panel li,
.post-content li {
  margin: 0.35em 0;
}

.content-panel blockquote,
.post-content blockquote {
  margin: 1.6em 0;
  padding: 0.35em 0 0.35em 1.1em;
  border-left: 4px solid var(--lake);
  color: var(--muted);
  background: rgba(60, 128, 120, 0.06);
}

.content-panel code,
.post-content code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: rgba(201, 155, 84, 0.18);
  color: var(--ember);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.content-panel pre,
.post-content pre {
  overflow-x: auto;
  padding: 18px;
  border-radius: 8px;
  background: #172431;
  color: #f3eadc;
  line-height: 1.6;
}

.content-panel pre code,
.post-content pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.post-list {
  display: grid;
  gap: 12px;
  padding: 0;
  list-style: none;
}

.post-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.post-list li:last-child {
  border-bottom: 0;
}

.post-list a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.post-list a:hover {
  color: var(--ember);
}

.post-list time,
.post-list small {
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  white-space: nowrap;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 26px 0 34px;
}

.category-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), var(--paper-soft));
  color: var(--ink);
  text-decoration: none;
}

.category-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
}

.category-card span {
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

.category-card:hover {
  border-color: rgba(169, 71, 50, 0.42);
  color: var(--ink);
  transform: translateY(-1px);
}

.side-panel {
  position: sticky;
  top: 24px;
}

.side-section + .side-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.side-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-panel p,
.side-panel li {
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.75;
}

.side-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-panel a {
  text-decoration: none;
}

.post-page {
  width: min(860px, 100%);
  margin: 0 auto;
}

.post-header {
  padding: clamp(28px, 5vw, 52px) clamp(24px, 5vw, 58px) 0;
}

.post-meta {
  margin: 0 0 14px;
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.post-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.2;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.post-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

.post-content {
  padding: clamp(24px, 5vw, 58px);
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.post-nav a {
  max-width: 48%;
  color: #1a5f5a;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  text-decoration: none;
}

.site-footer {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 18px 0 34px;
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  text-align: center;
}

.writer-panel {
  width: min(920px, 100%);
  margin: 0 auto;
}

.writer-form {
  display: grid;
  gap: 20px;
}

.writer-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.writer-field {
  display: grid;
  gap: 8px;
}

.writer-field label {
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.writer-field input,
.writer-field select,
.writer-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--field-ink);
  font: inherit;
  line-height: 1.6;
}

.writer-field input,
.writer-field select {
  min-height: 46px;
  padding: 8px 12px;
}

.writer-field textarea {
  resize: vertical;
  min-height: 120px;
  padding: 12px;
}

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

.writer-editor {
  --writer-body-width: 50%;
  display: flex;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--field);
}

.writer-pane {
  display: grid;
  grid-template-rows: auto auto;
  min-width: 0;
}

.writer-source-pane {
  flex: 0 0 var(--writer-body-width);
  min-width: 220px;
  max-width: calc(100% - 220px);
  border-right: 1px solid var(--line);
}

.writer-preview-pane {
  flex: 1 1 auto;
  min-width: 220px;
}

.writer-pane label {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(60, 128, 120, 0.06);
}

.writer-pane textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
}

#post-body {
  display: block;
  width: 100%;
  min-height: 360px;
  min-width: 220px;
  max-height: 78vh;
  max-width: calc(var(--writer-editor-width, 920px) - 220px);
  padding: 12px;
  resize: both;
  color: var(--field-ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.6;
}

.writer-preview {
  overflow: auto;
  height: var(--writer-body-height, 492px);
  min-height: 360px;
  max-height: 78vh;
  padding: 18px;
  background: transparent;
}

.writer-preview:empty::before {
  content: "Markdown 预览会显示在这里。";
  color: var(--muted);
}

.writer-preview h1,
.writer-preview h2,
.writer-preview h3 {
  margin-top: 1.4em;
  line-height: 1.35;
}

.writer-preview h1:first-child,
.writer-preview h2:first-child,
.writer-preview h3:first-child {
  margin-top: 0;
}

.writer-preview h1 {
  font-size: 28px;
}

.writer-preview h2 {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: 23px;
}

.writer-preview p {
  margin: 1em 0;
}

.writer-preview ul,
.writer-preview ol {
  padding-left: 1.4em;
}

.writer-preview blockquote {
  margin: 1.2em 0;
  padding-left: 1em;
  border-left: 4px solid var(--lake);
  color: var(--muted);
}

.writer-preview pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 8px;
  background: #111b24;
  color: #f4eadb;
  line-height: 1.6;
}

.writer-preview code {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: rgba(201, 155, 84, 0.18);
  color: var(--ember);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.writer-preview pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.writer-field input:focus,
.writer-field select:focus,
.writer-field textarea:focus {
  border-color: rgba(60, 128, 120, 0.72);
  box-shadow: 0 0 0 3px rgba(60, 128, 120, 0.16);
  outline: 0;
}

.writer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

.writer-button {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid #1e706b;
  border-radius: 8px;
  background: #1e706b;
  color: #fff8ec;
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 800;
}

.writer-button:hover {
  background: #185b57;
}

.writer-button.secondary {
  border-color: var(--line);
  background: transparent;
  color: #1e706b;
}

.writer-button.secondary:hover {
  border-color: rgba(169, 71, 50, 0.42);
  color: var(--ember);
}

.writer-status {
  color: var(--muted);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

@media (max-width: 860px) {
  body {
    font-size: 17px;
  }

  .site-hero {
    min-height: 390px;
    padding: 24px 18px 82px;
  }

  .site-nav {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 48px;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .post-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .writer-row {
    grid-template-columns: 1fr;
  }

  .writer-load-row {
    grid-template-columns: 1fr;
  }

  .writer-editor {
    display: grid;
    grid-template-columns: 1fr;
  }

  .writer-pane {
    min-height: 0;
  }

  .writer-source-pane {
    max-width: none;
    border-right: 0;
  }

  #post-body {
    max-width: 100%;
    resize: vertical;
  }

  .writer-preview-pane {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .page-wrap {
    width: min(100% - 24px, 1080px);
  }

  .content-panel,
  .side-panel,
  .post-header,
  .post-content {
    padding: 22px;
  }

  .hero-title {
    font-size: 40px;
  }

  .hero-description {
    font-size: 17px;
  }

  .post-nav {
    flex-direction: column;
  }

  .post-nav a {
    max-width: 100%;
  }
}

/* === Scroll Wallpaper Background === */
.wallpaper-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.wallpaper-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(16, 33, 52, 0.5) 0%,
    rgba(16, 33, 52, 0.25) 40%,
    rgba(16, 33, 52, 0.45) 100%
  );
}

:root[data-theme="dark"] .wallpaper-bg::after {
  background: linear-gradient(
    180deg,
    rgba(8, 16, 23, 0.6) 0%,
    rgba(8, 16, 23, 0.3) 40%,
    rgba(8, 16, 23, 0.55) 100%
  );
}

.wallpaper-bg.visible {
  opacity: 1;
}
