:root {
  --font-serif: "Source Serif 4", "Source Serif 4 Fallback";
  --bg: #ffffff;
  --surface: #f7f5f0;
  --surface-strong: #eee9df;
  --text: #1d1b17;
  --muted: #676157;
  --line: #ded8cc;
  --accent: #2f6858;
  --accent-strong: #214b40;
  --accent-soft: #e6f0ec;
  --danger: #8a2f2f;
  --shadow: 0 18px 50px rgba(29, 27, 23, 0.08);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #181714;
  --surface: #22201c;
  --surface-strong: #302d27;
  --text: #f3eee5;
  --muted: #bcb3a5;
  --line: #403b33;
  --accent: #91c7b7;
  --accent-strong: #bbe1d5;
  --accent-soft: #263a34;
  --danger: #eba4a4;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif, "Source Serif 4"), Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

.skip-link,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  z-index: 10;
  top: 12px;
  left: 12px;
  width: auto;
  height: auto;
  padding: 10px 14px;
  clip: auto;
  background: var(--text);
  color: var(--bg);
}

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

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 12px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.search-form {
  display: none;
  grid-column: 1 / -1;
  grid-row: 2;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.site-header.search-open .search-form {
  display: grid;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

button,
.pager-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.pager-link:hover,
.secondary-link:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.nav-controls {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-self: end;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25;
}

.theme-toggle {
  color: var(--text);
}

.icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

.app-shell {
  width: min(100%, 920px);
  min-height: calc(100vh - 210px);
  margin: 0 auto;
  padding: 28px 16px 52px;
}

.app-shell:focus {
  outline: none;
}

.view-header {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

h1,
h2,
h3,
h4 {
  line-height: 1.14;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 10vw, 3.45rem);
  letter-spacing: 0;
}

h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 7vw, 1.9rem);
  letter-spacing: 0;
}

h3 {
  margin: 24px 0 8px;
  font-size: 1.2rem;
}

.lede {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.post-list {
  display: grid;
  gap: 16px;
}

.post-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.post-card h2 {
  font-size: clamp(1.35rem, 6vw, 2rem);
}

.post-card a {
  color: var(--text);
  text-decoration: none;
}

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

.post-meta,
.tag-list,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 2px 10px;
  font-size: 0.9rem;
}

.post-summary {
  margin: 12px 0;
  color: var(--muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
}

.pager-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pager-link[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty-state,
.error-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}

.error-state {
  color: var(--danger);
}

.article {
  max-width: 740px;
  margin: 0 auto;
}

.article-header {
  margin-bottom: 22px;
}

.article-title {
  max-width: 720px;
  font-size: clamp(2.15rem, 8vw, 3.75rem);
}

.article-meta {
  margin-top: 12px;
}

.article-header .tag-list {
  margin-top: 8px;
}

.article-content {
  font-size: 1.04rem;
}

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

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content pre {
  margin: 0 0 18px;
}

.article-content h1 {
  margin: 30px 0 12px;
  font-size: clamp(1.8rem, 7vw, 2.45rem);
}

.article-content h2 {
  margin: 28px 0 10px;
  font-size: clamp(1.55rem, 6vw, 2rem);
}

.article-content h3 {
  margin: 22px 0 8px;
}

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

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

.article-content code {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  padding: 0.05em 0.28em;
  font-size: 0.88em;
}

.article-content pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  line-height: 1.45;
}

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

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (min-width: 720px) {
  .header-inner {
    grid-template-columns: auto minmax(280px, 1fr) auto;
    align-items: center;
    padding: 14px 24px;
  }

  .search-form {
    display: grid;
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .nav-controls {
    grid-column: auto;
    grid-row: auto;
  }

  .search-toggle {
    display: none;
  }

  .app-shell {
    padding: 40px 24px 64px;
  }

  .post-card {
    padding: 24px;
  }

}

@media (min-width: 1024px) {
  .app-shell {
    width: min(100%, 1040px);
  }
}
