:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #59636f;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --soft: #f4f6fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.06);
  --font: system-ui, -apple-system, Segoe UI, Roboto, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --fg: #e6eaf0;
    --muted: #b2bcc8;
    --line: #243042;
    --soft: #0f1520;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #59636f;
  --line: #e5e7eb;
  --soft: #f4f6fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0f14;
  --fg: #e6eaf0;
  --muted: #b2bcc8;
  --line: #243042;
  --soft: #0f1520;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button,
input {
  font: inherit;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
}

.header-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.brandmark {
  min-width: 0;
  color: var(--fg);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.search-form {
  display: flex;
  min-width: 0;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  background: var(--soft);
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.header-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  font-size: 13px;
}

.lang-switch a {
  color: var(--muted);
  white-space: nowrap;
}

.lang-switch a.on {
  color: var(--fg);
  font-weight: 700;
}

.theme-toggle {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  background: transparent;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--soft);
}

.cat-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-top: 8px;
  padding-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

.cat-link {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.cat-link:hover {
  color: var(--fg);
  background: var(--soft);
  text-decoration: none;
}

.cat-link.active {
  color: var(--accent-ink);
  background: var(--accent);
}

/* Main */

.page-body {
  padding-top: 28px;
  padding-bottom: 44px;
}

.home-hero {
  width: 100%;
  padding: 28px 20px 10px;
}

.site-title {
  max-width: 100%;
  margin: 0 0 6px;
  color: var(--fg);
  font-size: 34px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.site-tagline {
  max-width: 72ch;
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Home groups */

.group-block + .group-block {
  margin-top: 22px;
}

.group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}

.group-title {
  min-width: 0;
  margin: 0;
  color: var(--fg);
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.group-title a {
  color: var(--fg);
}

.group-more {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Cards */

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

.post-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.post-card-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

.post-card-meta {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.post-card-summary {
  margin: 8px 0 10px;
  overflow-wrap: anywhere;
}

.readmore {
  display: inline-block;
  font-weight: 600;
}

/* Lists */

.page-title {
  max-width: 100%;
  margin: 10px 0 8px;
  font-size: 26px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.post-flow {
  display: grid;
  gap: 14px;
}

.breadcrumbs {
  max-width: 100%;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* Articles */

.three-cols {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  gap: 28px;
}

.col-main {
  min-width: 0;
}

.article-view .meta-line {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.lead {
  color: var(--fg);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.article-body {
  max-width: 100%;
  margin-top: 14px;
  overflow-wrap: anywhere;
}

.article-body h2 {
  margin: 20px 0 8px;
  font-size: 22px;
  line-height: 1.35;
}

.article-body h3 {
  margin: 16px 0 6px;
  color: var(--fg);
  font-size: 18px;
  line-height: 1.4;
}

.article-body p {
  margin: 10px 0;
}

.article-body ul,
.article-body ol {
  margin: 10px 0;
  padding-left: 1.5em;
}

.article-body li {
  margin: 6px 0;
}

.article-body ol {
  margin-left: 0;
  padding-left: 0;
  border-left: 2px solid var(--line);
  list-style: none;
  counter-reset: step;
}

.article-body ol > li {
  position: relative;
  margin: 16px 0 16px 16px;
  padding-left: 40px;
  counter-increment: step;
}

.article-body ol > li::before {
  position: absolute;
  top: 0.15em;
  left: -16px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
  content: counter(step);
  font-size: 13px;
  font-weight: 700;
}

.article-body pre,
pre {
  max-width: 100%;
  padding: 12px 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  font: 13px/1.6 var(--mono);
}

.article-body code,
code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  background: var(--soft);
  font: 13px/1.5 var(--mono);
}

.article-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.article-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.article-body iframe,
.article-body video {
  max-width: 100%;
}

/* Side navigation */

.cat-sidenav,
.toc-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.cat-sidenav {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 160px);
  overflow: auto;
}

.sidenav-head {
  margin-bottom: 6px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sidenav-list,
.toc-list,
.related-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidenav-list li,
.related-list li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.sidenav-list a {
  color: var(--fg);
}

.sidenav-list .current a {
  color: var(--accent);
  font-weight: 700;
}

.toc-panel {
  min-width: 0;
  position: sticky;
  top: 92px;
  align-self: start;
}

.toc-list {
  font-size: 14px;
}

.toc-list li {
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.toc-list li.is-sub {
  margin-left: 14px;
}

.toc-list a {
  color: var(--muted);
}

.toc-list a:hover {
  color: var(--fg);
  text-decoration: none;
}

.related-block {
  margin-top: 28px;
}

.related-title {
  margin: 0 0 8px;
  font-size: 18px;
}

/* Pagination and footer */

.pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.pagination a {
  overflow-wrap: anywhere;
}

.page-next {
  text-align: right;
}

.site-footer {
  padding: 22px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-row > div {
  overflow-wrap: anywhere;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cta-button {
  display: inline-block;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cta-button:hover {
  opacity: 0.92;
  text-decoration: none;
}

.rss-link {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* Responsive layout */

@media (max-width: 1080px) {
  .three-cols {
    grid-template-columns: 220px minmax(0, 1fr) 260px;
    gap: 20px;
  }
}

@media (max-width: 860px) {
  .header-row {
    grid-template-areas:
      "brand tools"
      "search search";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brandmark {
    grid-area: brand;
  }

  .search-form {
    grid-area: search;
  }

  .header-tools {
    grid-area: tools;
    justify-content: flex-end;
  }

  .cat-nav {
    position: relative;
    clear: both;
  }

  .three-cols {
    grid-template-columns: minmax(0, 1fr);
  }

  .col-left,
  .col-right {
    display: none;
  }
}

@media (max-width: 560px) {
  .container {
    padding-right: 16px;
    padding-left: 16px;
  }

  .site-header {
    position: relative;
  }

  .header-row {
    grid-template-areas:
      "brand"
      "tools"
      "search";
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brandmark {
    width: 100%;
  }

  .header-tools {
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
  }

  .lang-switch {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    padding: 0;
  }

  .lang-switch a {
    padding: 4px 0;
  }

  .cta-button {
    flex: 0 1 auto;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .cat-nav {
    align-items: flex-start;
    gap: 6px;
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 10px;
  }

  .cat-link {
    padding-right: 9px;
    padding-left: 9px;
  }

  .page-body {
    padding-top: 20px;
  }

  .home-hero {
    padding: 20px 16px 10px;
  }

  .site-title {
    font-size: 30px;
  }

  .group-head {
    align-items: flex-start;
  }

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

  .pagination {
    gap: 8px;
    font-size: 14px;
  }
}
