:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #5f6672;
  --faint: #9aa1ac;
  --line: #e4e7ec;
  --line-soft: #edeff3;
  --accent: #2f6fed;
  --accent-strong: #1f56c4;
  --chip: #f1f3f6;
  --code-bg: #f3f4f7;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05), 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-lift: 0 2px 4px rgba(17, 24, 39, 0.06), 0 14px 32px rgba(17, 24, 39, 0.1);
  --radius: 14px;
  --radius-sm: 10px;
  --wide: 1180px;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --panel: #1e2127;
    --text: #e8eaed;
    --muted: #a3a9b3;
    --faint: #767d88;
    --line: #2e323a;
    --line-soft: #282c33;
    --accent: #6c9bff;
    --accent-strong: #8fb2ff;
    --chip: #262a31;
    --code-bg: #23262d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.45), 0 14px 32px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #5f6672;
  --faint: #9aa1ac;
  --line: #e4e7ec;
  --line-soft: #edeff3;
  --accent: #2f6fed;
  --accent-strong: #1f56c4;
  --chip: #f1f3f6;
  --code-bg: #f3f4f7;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05), 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-lift: 0 2px 4px rgba(17, 24, 39, 0.06), 0 14px 32px rgba(17, 24, 39, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171b;
  --panel: #1e2127;
  --text: #e8eaed;
  --muted: #a3a9b3;
  --faint: #767d88;
  --line: #2e323a;
  --line-soft: #282c33;
  --accent: #6c9bff;
  --accent-strong: #8fb2ff;
  --chip: #262a31;
  --code-bg: #23262d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.45), 0 14px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: 0.01em;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

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

svg {
  display: block;
}

.site-shell {
  width: min(100% - 48px, var(--wide));
  margin: 0 auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button:hover {
  background: var(--chip);
  color: var(--text);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
}

.brand {
  color: var(--text);
  font-size: 1.22rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.01em;
}

.brand:hover {
  color: var(--text);
}

.site-nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 60px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-toggle .icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  background: linear-gradient(135deg, #5a6a92, #8c89a8 55%, #c9a9a6);
  background-size: cover;
  background-position: center;
  color: #fff;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(23, 30, 48, 0.62) 0%, rgba(23, 30, 48, 0.28) 52%, rgba(23, 30, 48, 0.08) 100%);
}

.hero-inner {
  position: relative;
  padding: 88px 0 96px;
}

.hero-title {
  margin: 0;
  font-size: clamp(1.9rem, 4.4vw, 2.9rem);
  line-height: 1.42;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 18px rgba(10, 16, 32, 0.45);
}

.hero-subtitle {
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 12px rgba(10, 16, 32, 0.4);
}

.hero-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 34px;
  padding: 11px 22px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  transition: background 0.15s ease, transform 0.15s ease;
}

.hero-button svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.hero-button:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.hero-button:hover svg {
  transform: translateX(3px);
}

.hero-button--ghost {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}

.hero-button--ghost:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent-strong);
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
  padding: 36px 0 72px;
}

.page-single {
  width: min(100% - 48px, 860px);
  padding: 36px 0 72px;
}

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* ---------- Section head ---------- */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 20px;
}

.section-title {
  position: relative;
  margin: 0;
  padding-left: 14px;
  font-size: 1.18rem;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 1.05em;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--accent);
}

.section-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-more svg {
  width: 14px;
  height: 14px;
}

.section-more:hover {
  color: var(--accent);
}

/* ---------- Post cards ---------- */

.post-list {
  min-width: 0;
}

.post-card {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}

.post-card-media {
  display: block;
}

.post-card-cover {
  width: 100%;
  height: 118px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.post-card-cover--empty {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--panel)), color-mix(in srgb, var(--accent) 4%, var(--panel)));
  color: color-mix(in srgb, var(--accent) 55%, var(--muted));
}

.post-card-cover--empty svg {
  width: 34px;
  height: 34px;
}

.post-card-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  min-width: 0;
}

.post-card-title {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.45;
}

.post-card-title a {
  color: var(--text);
}

.post-card-title a:hover {
  color: var(--accent);
}

.post-card-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  color: var(--faint);
  font-size: 0.84rem;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.meta-item svg {
  width: 15px;
  height: 15px;
}

a.meta-link {
  color: var(--faint);
}

a.meta-link:hover {
  color: var(--accent);
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.profile-card {
  padding: 30px 26px;
  text-align: center;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

.card-title {
  margin: 0 0 10px;
  font-size: 1.08rem;
}

.profile-bio {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.profile-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.tags-card,
.recent-card {
  padding: 22px 24px;
}

.card-heading {
  margin: 0 0 10px;
  font-size: 1.02rem;
}

.tag-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-rows li + li {
  border-top: 1px solid var(--line-soft);
}

.tag-rows a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  color: var(--text);
  font-size: 0.93rem;
}

.tag-rows a:hover {
  color: var(--accent);
}

.tag-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.recent-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.recent-rows li {
  padding: 10px 2px;
}

.recent-rows li + li {
  border-top: 1px solid var(--line-soft);
}

.recent-rows a {
  display: block;
  color: var(--text);
  font-size: 0.93rem;
  line-height: 1.5;
}

.recent-rows a:hover {
  color: var(--accent);
}

.recent-rows time {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tags ---------- */

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 0.8rem;
}

.tag::before {
  content: "#";
  opacity: 0.55;
}

.tag:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-strong);
}

.tag--big {
  padding: 7px 16px;
  font-size: 0.92rem;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Article / pages ---------- */

.page-card {
  padding: clamp(24px, 4.5vw, 44px);
}

.article-header {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.article-header h1 {
  margin: 0 0 12px;
  font-size: clamp(1.6rem, 3.6vw, 2.2rem);
  line-height: 1.3;
}

.article-header .post-meta {
  margin-top: 2px;
}

.article-lede {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.article-body {
  font-size: 1.02rem;
  line-height: 1.85;
}

.article-body > :first-child {
  margin-top: 0;
}

.article-body > :last-child {
  margin-bottom: 0;
}

.article-body h2,
.article-body h3 {
  margin: 1.9em 0 0.6em;
  line-height: 1.35;
}

.article-body h2 {
  font-size: 1.4rem;
}

.article-body h3 {
  font-size: 1.16rem;
}

.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote,
.article-body pre {
  margin: 1.1em 0;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
}

.article-body li {
  margin: 0.35em 0;
}

.article-body li::marker {
  color: var(--faint);
}

.article-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 10px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--chip);
  color: var(--muted);
}

.article-body blockquote p {
  margin: 0.4em 0;
}

.article-body a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 0.2em;
}

.article-body img {
  border-radius: var(--radius-sm);
}

.article-body code {
  border-radius: 5px;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  font-family: var(--mono);
  font-size: 0.88em;
}

.article-body pre {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  padding: 16px 18px;
  line-height: 1.6;
}

.article-body pre code {
  background: transparent;
  padding: 0;
  font-size: 0.86rem;
}

.article-body hr {
  height: 0;
  margin: 2.4em auto;
  width: 45%;
  border: 0;
  border-top: 1px solid var(--line);
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.95rem;
}

.article-body th,
.article-body td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.article-body th {
  color: var(--faint);
  font-weight: 600;
}

/* ---------- Archive ---------- */

.archive-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-row {
  display: flex;
  align-items: baseline;
  gap: 22px;
  padding: 14px 2px;
}

.archive-row + .archive-row {
  border-top: 1px solid var(--line-soft);
}

.archive-row time {
  flex: none;
  width: 6.4em;
  color: var(--faint);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.archive-row a {
  color: var(--text);
  font-size: 1rem;
}

.archive-row a:hover {
  color: var(--accent);
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
  padding: 26px 0;
  color: var(--faint);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}

.site-footer a {
  color: var(--faint);
}

.site-footer a:hover {
  color: var(--accent);
}

.empty {
  padding: 32px 0;
  color: var(--faint);
  list-style: none;
  text-align: center;
}

/* ---------- Not found ---------- */

.article--center {
  text-align: center;
}

.article--center .article-header {
  border-bottom: 0;
  margin-bottom: 4px;
  padding-bottom: 0;
}

.lost-code {
  margin: 12px 0 0;
  color: color-mix(in srgb, var(--accent) 30%, var(--line));
  font-size: clamp(4rem, 10vw, 6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.06em;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar .card {
    flex: 1 1 300px;
  }
}

@media (max-width: 640px) {
  .site-shell {
    width: min(100% - 32px, var(--wide));
  }

  .page-single {
    width: min(100% - 32px, 860px);
  }

  .header-inner {
    gap: 12px;
  }

  .site-nav {
    gap: 0;
  }

  .site-nav a {
    padding: 0 9px;
    font-size: 0.9rem;
  }

  .hero-inner {
    padding: 60px 0 68px;
  }

  .post-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .post-card-cover {
    height: 160px;
  }

  .archive-row {
    flex-direction: column;
    gap: 2px;
  }

  .archive-row time {
    width: auto;
  }
}
