:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #14171a;
  --muted: #5d6773;
  --subtle: #8a94a3;
  --line: #d9dee5;
  --accent: #0f766e;
  --accent-2: #8a4b12;
  --danger: #b42318;
  --code-bg: #111827;
  --code-text: #e5e7eb;
  --shadow: 0 16px 40px rgba(20, 23, 26, .08);
  --radius: 8px;
  --max: 1180px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --surface: #171c21;
  --surface-2: #20272e;
  --text: #eef2f5;
  --muted: #a9b3bd;
  --subtle: #77828e;
  --line: #2c353e;
  --accent: #33b8a6;
  --accent-2: #f0a04a;
  --danger: #ff7568;
  --code-bg: #05080c;
  --code-text: #f3f4f6;
  --shadow: 0 18px 48px rgba(0, 0, 0, .26);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
}

body::selection {
  background: rgba(15, 118, 110, .18);
}

a {
  color: inherit;
  text-decoration-color: rgba(15, 118, 110, .42);
  text-underline-offset: .18em;
}

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

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-inner,
.footer-inner,
.site-main {
  width: min(100% - 40px, var(--max));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  object-fit: cover;
  box-shadow: var(--shadow);
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-name,
.brand-line {
  display: block;
}

.brand-name {
  font-size: 16px;
  font-weight: 760;
}

.brand-line {
  max-width: 420px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.site-nav a,
.theme-toggle,
.read-link,
.back-link,
.pager a {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
}

.site-nav a:hover,
.theme-toggle:hover,
.read-link:hover,
.back-link:hover,
.pager a:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  background: transparent;
  cursor: pointer;
}

.theme-toggle-icon {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 6px -4px 0 currentColor;
}

.site-main {
  padding: 36px 0 56px;
}

.home-shell {
  display: grid;
  gap: 30px;
  align-items: start;
}

.home-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 0 30px;
  border-bottom: 1px solid var(--line);
}

.home-hero h1 {
  max-width: 760px;
  font-size: 48px;
  line-height: 1.06;
}

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

.home-tools {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 760;
  line-height: 1.22;
  letter-spacing: 0;
}

.article-header h1,
.list-header h1 {
  font-size: 34px;
}

.list-header p,
.post-card-summary {
  margin: 0;
  color: var(--muted);
}

.site-stats {
  display: grid;
  grid-template-columns: minmax(58px, .8fr) minmax(58px, .8fr) minmax(112px, 1.3fr);
  gap: 14px;
  width: min(100%, 420px);
  margin: 0;
}

.site-stats div {
  min-width: 0;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

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

.site-stats dd {
  margin: 2px 0 0;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.search-box {
  display: grid;
  gap: 8px;
}

.search-box label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.search-box input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}

.search-results {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-results p {
  margin: 0;
  padding: 10px;
  color: var(--muted);
}

.search-results a {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.search-results a:last-child {
  border-bottom: 0;
}

.search-results strong {
  font-size: 14px;
}

.search-results span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag-cloud,
.tag-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-cloud a,
.tag-index a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.tag-index a {
  min-height: 44px;
  padding: 9px 12px;
  font-size: 15px;
}

.tag-index strong {
  color: var(--accent-2);
}

.home-feed,
.list-page {
  display: grid;
  gap: 18px;
}

.section-heading {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-size: 24px;
}

.post-list {
  display: grid;
  gap: 0;
}

.post-card {
  display: grid;
  gap: 10px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.post-card:hover {
  border-bottom-color: color-mix(in srgb, var(--accent) 38%, var(--line));
}

.post-card-meta,
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--subtle);
}

.post-card-title {
  font-size: 24px;
}

.post-card-title a {
  text-decoration: none;
}

.read-link {
  justify-self: start;
  color: var(--accent);
  font-weight: 680;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  color: var(--muted);
}

.article-shell,
.list-page {
  width: min(100%, 1060px);
  margin: 0 auto;
}

.article-header,
.list-header {
  display: grid;
  gap: 12px;
  padding: 16px 0 28px;
  border-bottom: 1px solid var(--line);
}

.article-header h1 {
  max-width: 900px;
}

.back-link {
  justify-self: start;
  color: var(--accent);
  font-weight: 680;
}

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px) 240px;
  gap: 42px;
  align-items: start;
  padding-top: 30px;
}

.article-content {
  min-width: 0;
  font-size: 17px;
}

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

.article-content h2,
.article-content h3,
.article-content h4 {
  margin-top: 2.1em;
  margin-bottom: .7em;
  scroll-margin-top: 96px;
}

.article-content h2 {
  padding-top: .2em;
  border-top: 1px solid var(--line);
  font-size: 26px;
}

.article-content h3 {
  font-size: 21px;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content table,
.article-content blockquote,
.article-content figure {
  margin: 1em 0;
}

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

.article-content li + li {
  margin-top: .35em;
}

.article-content blockquote {
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.article-content code {
  padding: .12em .36em;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--danger);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  overflow-wrap: break-word;
}

.article-content a {
  color: var(--accent);
}

.article-content img {
  display: block;
  margin: 18px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.article-content table:not(.highlight table) {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}

.article-content > table:not(.highlight table) thead,
.article-content > table:not(.highlight table) tbody {
  display: table;
  min-width: 100%;
}

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

.article-content th {
  background: var(--surface-2);
  font-weight: 760;
}

.highlight {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
}

.highlight table {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
  border: 0;
  border-collapse: collapse;
}

.highlight tbody {
  display: block;
  width: 100%;
}

.highlight tr {
  display: flex;
  width: 100%;
}

.highlight tr,
.highlight td {
  border: 0;
}

.highlight .gutter {
  flex: 0 0 auto;
  padding: 14px 10px;
  background: color-mix(in srgb, var(--code-bg) 86%, white);
  color: #7c8795;
  text-align: right;
  user-select: none;
  white-space: nowrap;
}

.highlight .code {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  padding: 14px 16px;
}

.highlight pre,
.highlight code,
pre {
  margin: 0;
  background: transparent;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre;
}

.highlight code {
  padding: 0;
  border: 0;
}

.article-sidebar {
  position: sticky;
  top: 104px;
}

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

.toc-title {
  margin: 0 0 10px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.js-toc {
  display: grid;
  gap: 7px;
}

.js-toc a {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
}

.js-toc .toc-child {
  padding-left: 12px;
}

.timeline {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.timeline h2 {
  margin-top: 24px;
  color: var(--accent);
  font-size: 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-item time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline-item a {
  font-weight: 680;
  text-decoration: none;
}

.empty-state {
  margin: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 0;
  font-size: 13px;
}

@media (max-width: 920px) {
  .home-layout,
  .article-grid {
    grid-template-columns: 1fr;
  }

  .home-tools,
  .article-sidebar {
    position: static;
  }

  .article-sidebar {
    order: -1;
  }
}

@media (max-width: 680px) {
  .header-inner,
  .footer-inner,
  .site-main {
    width: min(100% - 28px, var(--max));
  }

  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 0;
  }

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

  .brand-line {
    white-space: normal;
  }

  .home-hero {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 8px;
  }

  .home-hero h1,
  .article-header h1,
  .list-header h1 {
    font-size: 34px;
  }

  .article-content {
    font-size: 16px;
  }

  .article-content h2 {
    font-size: 23px;
  }

  .site-stats {
    grid-template-columns: minmax(58px, .8fr) minmax(58px, .8fr) minmax(112px, 1.3fr);
    width: 100%;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .footer-inner {
    flex-direction: column;
  }
}
