:root {
  color-scheme: light;
  --bg: #f8faf9;
  --surface: #ffffff;
  --surface-soft: #eef4f2;
  --ink: #17201d;
  --muted: #61716b;
  --subtle: #8c9b95;
  --line: #dce5e1;
  --accent: #147d64;
  --accent-strong: #0b5e4a;
  --blue: #2563eb;
  --amber: #b7791f;
  --coral: #c84f3a;
  --code-bg: #111817;
  --code-ink: #d7ece6;
  --shadow: 0 18px 50px rgba(23, 32, 29, 0.08);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1514;
  --surface: #17201e;
  --surface-soft: #1f2b28;
  --ink: #edf7f3;
  --muted: #b1c0ba;
  --subtle: #7d918a;
  --line: #2b3a36;
  --accent: #59d6ad;
  --accent-strong: #91e4c8;
  --blue: #8fb6ff;
  --amber: #e0b15d;
  --coral: #f08a75;
  --code-bg: #09100f;
  --code-ink: #e0f2ed;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(20, 125, 100, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  overflow-x: hidden;
}

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

img {
  max-width: 100%;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  transform: translateY(-150%);
  padding: 0.55rem 0.8rem;
  color: #ffffff;
  background: var(--accent-strong);
  border-radius: 6px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto minmax(8rem, 1fr);
  gap: 1rem;
  align-items: center;
  min-height: 72px;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  width: fit-content;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-strong), var(--blue));
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.top-nav {
  display: inline-flex;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.28rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.top-nav a,
.ghost-button,
.icon-button {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 0.9rem;
  line-height: 1.2;
}

.top-nav a:hover,
.top-nav a.active,
.ghost-button:hover,
.icon-button:hover {
  color: var(--ink);
  background: var(--surface);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.ghost-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
}

.icon-button {
  width: 40px;
  padding: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: clamp(1.2rem, 3vw, 2.4rem);
  width: min(1280px, calc(100% - 2rem));
  margin: 2rem auto 0;
  min-width: 0;
}

.profile-panel {
  position: sticky;
  top: 96px;
  align-self: start;
  min-width: 0;
  max-width: 100%;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.profile-panel > *,
.content,
.home-head,
.page-head,
.article-head,
.terminal-card,
.site-stats {
  min-width: 0;
  max-width: 100%;
}

.avatar {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.profile-copy {
  padding: 1rem 0.25rem 0;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.profile-copy h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.2;
}

.profile-copy p:not(.eyebrow) {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 0.25rem;
}

.profile-links a,
.tag,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.28rem 0.6rem;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1.2;
}

.profile-links a:hover,
.chip:hover,
.chip.active {
  color: var(--surface);
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.site-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}

.site-stats div {
  padding: 0.8rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.site-stats dt {
  color: var(--subtle);
  font-size: 0.72rem;
}

.site-stats dd {
  margin: 0.1rem 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.content {
  min-width: 0;
}

.home-head,
.page-head,
.article-head {
  display: grid;
  gap: 1rem;
  padding: clamp(1.1rem, 3vw, 1.8rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.home-head {
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
}

.home-head h2,
.page-head h2,
.article-head h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 2.72rem);
  line-height: 1.18;
}

.home-head p,
.page-head p,
.article-head p {
  max-width: 64ch;
  margin: 0;
  color: var(--muted);
}

.terminal-card {
  align-self: stretch;
  overflow: hidden;
  min-height: 220px;
  background: var(--code-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, #000000);
  border-radius: 7px;
}

.terminal-bar {
  display: flex;
  gap: 0.38rem;
  align-items: center;
  height: 34px;
  padding: 0 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dot:nth-child(1) {
  background: #f87171;
}

.terminal-dot:nth-child(2) {
  background: #fbbf24;
}

.terminal-dot:nth-child(3) {
  background: #34d399;
}

.terminal-card pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  color: var(--code-ink);
  font-size: 0.86rem;
  line-height: 1.65;
}

.command {
  color: #86efac;
}

.muted-line {
  color: #8fafaa;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  margin: 1rem 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 48px;
  padding: 0.35rem 0.45rem 0.35rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-box span {
  color: var(--subtle);
  font-size: 0.84rem;
  white-space: nowrap;
}

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

.filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.5rem;
}

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

.post-card,
.project-card,
.uses-card,
.deploy-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-card {
  display: grid;
  min-height: 100%;
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.post-cover {
  width: 100%;
  aspect-ratio: 16 / 8.5;
  object-fit: cover;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.post-body {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--subtle);
  font-size: 0.8rem;
}

.post-card h3,
.project-card h3,
.uses-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.35;
}

.post-card p,
.project-card p,
.uses-card p,
.deploy-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  color: var(--muted);
  background: var(--surface-soft);
  border-color: var(--line);
}

.section-title {
  margin: 1.8rem 0 0.85rem;
  font-size: 1rem;
}

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

.deploy-card,
.project-card,
.uses-card {
  padding: 1rem;
}

.deploy-card strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--accent-strong);
}

.project-card {
  display: grid;
  gap: 0.65rem;
}

.project-card .status {
  width: fit-content;
  padding: 0.18rem 0.48rem;
  color: var(--surface);
  background: var(--blue);
  border-radius: 999px;
  font-size: 0.75rem;
}

.project-card:nth-child(2) .status {
  background: var(--accent-strong);
}

.project-card:nth-child(3) .status {
  background: var(--coral);
}

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

.article-head {
  margin-bottom: 1rem;
}

.article-cover {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  margin-top: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.article-content {
  padding: clamp(1.2rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.article-content h3 {
  margin: 1.7rem 0 0.5rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

.article-content h2 {
  margin: 2rem 0 0.6rem;
  font-size: 1.45rem;
  line-height: 1.3;
}

.article-content h2:first-child,
.article-content h3:first-child {
  margin-top: 0;
}

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

.article-content a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.article-content ul,
.article-content ol {
  padding-left: 1.25rem;
  color: var(--muted);
}

.article-content li + li {
  margin-top: 0.35rem;
}

.article-content blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 1rem;
  color: var(--muted);
  background: var(--surface-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}

.article-content img {
  display: block;
  max-width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.article-content pre {
  overflow-x: auto;
  padding: 1rem;
  color: var(--code-ink);
  background: var(--code-bg);
  border-radius: 7px;
  line-height: 1.6;
}

.article-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

.toc {
  position: sticky;
  top: 96px;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toc strong {
  display: block;
  margin-bottom: 0.55rem;
}

.toc a {
  display: block;
  padding: 0.25rem 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.toc-level-3 {
  padding-left: 0.8rem !important;
}

.toc-empty {
  display: block;
  color: var(--subtle);
  font-size: 0.88rem;
}

.back-link {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 0.8rem;
  color: var(--accent-strong);
  font-weight: 700;
}

.empty-state {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.notice {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line));
  border-radius: var(--radius);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(1280px, calc(100% - 2rem));
  margin: 2rem auto;
  padding: 1rem 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

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

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .app-shell,
  .home-head,
  .article-layout {
    grid-template-columns: 1fr;
  }

  .profile-panel,
  .toc {
    position: static;
  }

  .profile-panel {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1rem;
  }

  .profile-links,
  .site-stats {
    grid-column: 1 / -1;
  }

  .post-grid,
  .deploy-grid,
  .project-grid,
  .uses-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    background-size: 30px 30px;
  }

  .site-header {
    padding: 0.8rem 1rem;
  }

  .brand small {
    display: none;
  }

  .app-shell {
    width: min(calc(100% - 1rem), 360px);
    margin-top: 0.75rem;
  }

  .profile-panel {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }

  .header-actions .ghost-button {
    display: none;
  }

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

  .filter-row {
    justify-content: flex-start;
  }

  .home-head h2,
  .page-head h2,
  .article-head h2 {
    font-size: 1.75rem;
  }

  .site-footer {
    display: grid;
    width: min(calc(100% - 1rem), 360px);
  }
}
