:root {
  color-scheme: light;
  --accent: #c74634;
  --accent-text: #b53d2c;
  --on-accent: #fff;
  --bg: #fff;
  --surface: #f6f7f8;
  --text: #15171a;
  --muted: #5f6b73;
  --border: #e3e6e8;
  --code-bg: #15171a;
  --code-text: #e8eaec;
  --inline-code-bg: #f0f1f3;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --serif: Georgia, Times, serif;
  --mono: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  --page: 1200px;
  --reading: 720px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent-text: #ef8473;
  --bg: #151719;
  --surface: #1e2124;
  --text: #e8eaec;
  --muted: #a3adb4;
  --border: #2e3236;
  --code-bg: #0c0d0e;
  --inline-code-bg: #282b2f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --accent-text: #ef8473;
    --bg: #151719;
    --surface: #1e2124;
    --text: #e8eaec;
    --muted: #a3adb4;
    --border: #2e3236;
    --code-bg: #0c0d0e;
    --inline-code-bg: #282b2f;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

main { flex: 1; width: 100%; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: calc(var(--page) + 48px); margin-inline: auto; padding-inline: 24px; }

.skip-link { position: absolute; left: 16px; top: -48px; padding: 8px 12px; background: var(--accent); color: var(--on-accent); z-index: 10; }
.skip-link:focus { top: 8px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; }
.site-name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.site-header nav { display: flex; align-items: center; gap: 18px; font-size: 15px; font-weight: 500; }
.site-header nav > a:not(.button) { text-decoration: none; color: var(--muted); }
.site-header nav > a:not(.button):hover { color: var(--text); }

.button {
  display: inline-block;
  padding: 7px 15px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { filter: brightness(0.92); }

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface); }

/* Intro */
.intro { padding-block: 56px 36px; }
.intro h1 { margin: 0 0 8px; font-size: clamp(32px, 5vw, 48px); line-height: 1.1; letter-spacing: -0.025em; }
.intro p { margin: 0; max-width: 640px; color: var(--muted); font-size: 18px; }
.eyebrow { color: var(--accent-text) !important; font-size: 13px !important; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.not-found { text-align: center; padding-block: 96px; }
.not-found p { margin-inline: auto; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 44px 32px; padding-bottom: 56px; }
.card { display: flex; flex-direction: column; min-width: 0; }
.entry-image { display: block; margin-bottom: 16px; overflow: hidden; border-radius: 6px; background: var(--surface); aspect-ratio: 16 / 9; }
.entry-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.card:hover .entry-image img { transform: scale(1.02); }
.entry-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.entry-title { margin: 0 0 8px; font-size: 22px; line-height: 1.22; letter-spacing: -0.015em; }
.entry-title a { text-decoration: none; }
.entry-title a:hover { color: var(--accent-text); }
.entry-excerpt { margin: 0 0 14px; color: var(--muted); font-size: 15px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; color: var(--muted); font-size: 13px; }

.card-feature { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 40px; align-items: center; padding-bottom: 44px; border-bottom: 1px solid var(--border); }
.card-feature.card-no-image { display: block; }
.card-no-image .entry-meta { margin-top: 0; }
.card-feature .entry-image { margin-bottom: 0; }
.card-feature .entry-title { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.12; letter-spacing: -0.025em; }
.card-feature .entry-excerpt { font-size: 17px; -webkit-line-clamp: 4; line-clamp: 4; }
.card-feature .entry-meta { margin-top: 0; }
.empty { grid-column: 1 / -1; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.tag { color: var(--accent-text); font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-decoration: none; text-transform: uppercase; }
.tag:hover { text-decoration: underline; }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; padding-block: 0 56px; color: var(--muted); font-size: 14px; }
.pager a { color: var(--text); font-weight: 600; text-decoration: none; }
.pager a:hover { color: var(--accent-text); }
.pager > :last-child { text-align: right; }

/* Article */
.post { width: 100%; padding: 56px 24px 24px; }
.post-header, .post-body, .follow { max-width: var(--reading); margin-inline: auto; }
.post-header h1 { margin: 4px 0 14px; font-size: clamp(32px, 5vw, 48px); line-height: 1.1; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.post-standfirst { margin: 0 0 20px; color: var(--muted); font-family: var(--serif); font-size: 20px; line-height: 1.45; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding-bottom: 28px; font-size: 14px; }
.byline .entry-meta { margin: 0; }
.post-cover { max-width: 1040px; margin: 0 auto 40px; }
.post-cover img { width: 100%; max-height: 560px; object-fit: cover; border-radius: 6px; }

.post-body { font-family: var(--serif); font-size: 19px; line-height: 1.72; overflow-wrap: break-word; }
.post-body > :first-child { margin-top: 0; }
.post-body p, .post-body ul, .post-body ol, .post-body blockquote, .post-body pre, .post-body figure, .post-body table { margin-block: 0 1.25em; }
.post-body h2, .post-body h3, .post-body h4 { font-family: var(--sans); line-height: 1.22; letter-spacing: -0.015em; }
.post-body h2 { margin: 1.9em 0 0.6em; font-size: 28px; }
.post-body h3 { margin: 1.6em 0 0.5em; font-size: 22px; }
.post-body h4 { margin: 1.4em 0 0.4em; font-size: 18px; }
.post-body a { color: var(--accent-text); text-underline-offset: 2px; }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li { margin-bottom: 0.35em; }
.post-body li > p { margin-bottom: 0.35em; }
.post-body img { margin-inline: auto; border-radius: 4px; }
.post-body figure { margin-inline: 0; }
.post-body figcaption { margin-top: 8px; color: var(--muted); font-family: var(--sans); font-size: 14px; text-align: center; }
.post-body blockquote { margin-inline: 0; padding-left: 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.post-body hr { margin-block: 2.5em; border: 0; border-top: 1px solid var(--border); }
.post-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--sans); font-size: 15px; }
.post-body th, .post-body td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.post-body th { background: var(--surface); }
.post-body code { padding: 0.12em 0.34em; border-radius: 3px; background: var(--inline-code-bg); font-family: var(--mono); font-size: 0.84em; overflow-wrap: anywhere; }

.post-body pre {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  padding: 18px 20px;
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  tab-size: 2;
}
.post-body pre code { display: block; width: max-content; min-width: 100%; padding: 0; background: none; color: inherit; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.copy-code {
  position: sticky;
  left: calc(100% - 64px);
  display: block;
  width: 64px;
  height: 26px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  background: #282b2f;
  color: #e8eaec;
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}
.copy-code:hover { background: #3a3e43; }

.follow { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-top: 44px; padding: 22px 24px; border-radius: 6px; background: var(--surface); }
.follow p { margin: 0; font-weight: 600; }

.related { width: 100%; max-width: calc(var(--page) + 48px); margin: 36px auto 0; padding: 36px 24px 56px; border-top: 1px solid var(--border); }
.related h2 { margin: 0 0 22px; font-size: 22px; }
.related-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.related-link { display: block; margin-bottom: 6px; font-size: 18px; font-weight: 700; line-height: 1.3; text-decoration: none; }
.related-link:hover { color: var(--accent-text); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; min-height: 72px; padding-block: 16px; }
.footer-links { display: flex; gap: 18px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--text); }

@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-feature { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (max-width: 640px) {
  .wrap { padding-inline: 16px; }
  .header-inner { min-height: 60px; gap: 8px; }
  .site-name { font-size: 17px; }
  .site-header nav { gap: 10px; font-size: 14px; }
  .site-header .button { padding: 5px 10px; font-size: 13px; }
  .theme-toggle { width: 30px; height: 30px; }
  .intro { padding-block: 36px 24px; }
  .cards { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .post { padding: 36px 16px 16px; }
  .post-body { font-size: 18px; }
  .post-body h2 { font-size: 24px; }
  .post-standfirst { font-size: 18px; }
  .related { padding-inline: 16px; }
  .related-list { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 400px) {
  .site-name { font-size: 15px; }
  .site-header nav { gap: 7px; font-size: 13px; }
  .site-header .button { padding: 4px 8px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .entry-image img { transition: none; }
  .card:hover .entry-image img { transform: none; }
}
