:root {
  --bg: #ffffff;
  --fg: #14110f;
  --muted: #6b6b6b;
  --line: #ececec;
  --accent: #14110f;
  --maxw: 660px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  font-size: 18px;
}

.page { max-width: var(--maxw); margin: 0 auto; padding: 72px 24px 96px; }

/* Language switch */
.language-switch {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 44px;
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.language-switch a {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  line-height: 1;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.language-switch a:hover,
.language-switch a[aria-current="true"] {
  color: var(--fg);
  border-color: var(--fg);
}
.language-switch a[aria-current="true"] { background: var(--fg); color: var(--bg); }

/* Lede */
.lede {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 56px;
}
.site-mark {
  display: block;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
}
.site-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.lede h1 { font-size: 48px; letter-spacing: -0.03em; font-weight: 800; line-height: 1.05; }

/* Post list */
.post-list { display: flex; flex-direction: column; }
.entry { border-top: 1px solid var(--line); }
.entry:last-child { border-bottom: 1px solid var(--line); }
.entry-link {
  display: block; padding: 28px 0; text-decoration: none; color: inherit;
  transition: padding-left .2s ease;
}
.entry-link:hover { padding-left: 10px; }
.entry time { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.entry h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; margin: 8px 0 6px; line-height: 1.3; }
.entry p { font-size: 16px; color: var(--muted); max-width: 60ch; }

/* Footer */
.foot { margin-top: 72px; padding-top: 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot .social { margin-top: 16px; display: flex; gap: 18px; align-items: center; }
.foot .social a {
  display: inline-flex; color: var(--muted); line-height: 0;
  transition: color .15s ease, transform .15s ease;
}
.foot .social a:hover { color: var(--fg); transform: translateY(-2px); }
.foot .social svg { display: block; }
.foot .copyright { margin-top: 28px; font-size: 13px; color: var(--muted); }

/* Article */
.article { max-width: var(--maxw); margin: 0 auto; padding: 56px 24px 110px; }
.article .language-switch { margin-bottom: 28px; }
.back { font-size: 14px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 40px; }
.back:hover { color: var(--fg); }
.article-head time { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.article-head h1 { font-size: clamp(30px, 5vw, 40px); letter-spacing: -0.025em; line-height: 1.15; margin: 12px 0 0; }
.prose { margin-top: 44px; }
.prose p { margin-bottom: 24px; }
.prose h2 { font-size: 24px; letter-spacing: -0.01em; margin: 44px 0 16px; }
.prose blockquote {
  margin: 32px 0; padding-left: 22px; border-left: 3px solid var(--fg);
  font-style: italic; color: #333;
}
.prose a { color: var(--fg); text-underline-offset: 3px; }
.prose code { font-family: ui-monospace, Menlo, monospace; font-size: 0.88em; background: #f4f4f4; padding: 2px 6px; border-radius: 5px; }
.prose ul { margin: 0 0 24px 22px; }
.prose li { margin-bottom: 8px; }
.prose figure { margin: 32px 0; }
.prose figure.narrow-media {
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}
.prose figure img,
.article-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #f4f4f4;
}
.article-hero { margin: 36px 0 0; }
.prose figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 32px 0;
}
.image-grid figure { margin: 0; }
.image-grid img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.image-grid .portrait img { aspect-ratio: 3 / 4; }
.resource-list {
  list-style: none;
  margin: 0 0 28px;
  border-top: 1px solid var(--line);
}
.resource-list li {
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.resource-list a {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  color: inherit;
  text-decoration: none;
}
.resource-list a:hover { color: var(--muted); }
.resource-list span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}
.spec-list { margin-bottom: 28px; }
.note {
  margin: 28px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 16px;
}

/* Table of contents (chapters) */
.prose h2 { scroll-margin-top: 24px; }

.toc {
  margin: 0 0 36px;
  padding: 14px 18px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
}
.toc-label {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 12px 8px 0;
}
.toc ol { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  padding: 5px 12px 5px 0;
  border-right: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease, padding-right .15s ease;
}
.toc a:hover { color: var(--fg); padding-right: 16px; }
.toc a.is-active {
  color: var(--fg);
  border-right-color: var(--fg);
  font-weight: 600;
}

@media (min-width: 1120px) {
  .toc {
    position: fixed;
    top: 120px;
    right: calc(50% + 354px);
    width: 200px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 13px;
  }
  .toc-label { display: none; }
  .toc ol { gap: 2px; }
  .toc a { font-size: 13px; padding: 4px 12px 4px 0; }
  .toc a:hover { padding-right: 16px; }
}

@media (prefers-color-scheme: dark) {
  :root { --bg:#0f0f10; --fg:#f1efed; --muted:#9a9a9a; --line:#262626; }
  .prose code { background:#1c1c1e; }
  .prose blockquote { color:#cfcfcf; }
  .prose figure img,
  .article-hero img { background:#1c1c1e; }
}

@media (max-width: 540px) {
  body { font-size: 17px; }
  .lede { gap: 14px; }
  .site-mark { width: 60px; height: 60px; }
  .lede h1 { font-size: 38px; }
  .image-grid { grid-template-columns: 1fr; }
  .resource-list a { flex-direction: column; gap: 2px; }
  .resource-list span { font-size: 13px; }
}
