:root {
  color-scheme: light dark;
  --max: 42rem;

  /* paper (default) */
  --bg: light-dark(#fbfaf7, #171613);
  --surface: light-dark(#f2efe8, #22201c);
  --ink: light-dark(#24211d, #eae6df);
  --muted: light-dark(#736d64, #a39c91);
  --rule: light-dark(#ded9cf, #37332d);
  --accent: light-dark(#9b3f26, #e28b67);
  --accent-soft: light-dark(#f4e4dc, #35241d);
  --danger: light-dark(#a12d26, #f08a80);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

:root[data-palette="slate"] {
  --bg: light-dark(#f7f9fb, #12171c);
  --surface: light-dark(#eef2f6, #1b232b);
  --ink: light-dark(#1d242b, #e6edf3);
  --muted: light-dark(#64707c, #96a3b0);
  --rule: light-dark(#d7dfe7, #2c3742);
  --accent: light-dark(#2f6f9f, #79b8e6);
  --accent-soft: light-dark(#e0edf7, #1b2f3f);
  --danger: light-dark(#a8322a, #f08a80);
}

:root[data-palette="forest"] {
  --bg: light-dark(#f8faf5, #131811);
  --surface: light-dark(#eef3e8, #1c2318);
  --ink: light-dark(#20261c, #e6eddf);
  --muted: light-dark(#68715f, #9aa78f);
  --rule: light-dark(#d9e0d1, #303a29);
  --accent: light-dark(#3f6b3a, #8fc482);
  --accent-soft: light-dark(#e2eedd, #23331d);
  --danger: light-dark(#a8322a, #f08a80);
}

:root[data-palette="plum"] {
  --bg: light-dark(#fbf8fb, #181318);
  --surface: light-dark(#f3ecf4, #231b23);
  --ink: light-dark(#261f28, #ece3ed);
  --muted: light-dark(#74677a, #a697a8);
  --rule: light-dark(#e0d5e2, #3a2e3a);
  --accent: light-dark(#7b3f78, #d99bd3);
  --accent-soft: light-dark(#f0e0ef, #352235);
  --danger: light-dark(#a12d4a, #f08a9a);
}

:root[data-palette="mono"] {
  --bg: light-dark(#fafafa, #141414);
  --surface: light-dark(#f0f0f0, #1f1f1f);
  --ink: light-dark(#1d1d1d, #ebebeb);
  --muted: light-dark(#6e6e6e, #a0a0a0);
  --rule: light-dark(#dcdcdc, #333333);
  --accent: light-dark(#404040, #cfcfcf);
  --accent-soft: light-dark(#e6e6e6, #2b2b2b);
  --danger: light-dark(#a12d26, #f08a80);
}

* {
  box-sizing: border-box;
  border-radius: 0;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

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

a:hover { text-decoration-thickness: 2px; }

.site-header,
.site-footer,
main {
  width: min(calc(100% - 2.5rem), var(--max));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 2.2rem 0 1rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.86rem;
}

.site-name {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem 1.1rem;
}

.theme-switch {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule);
}

.theme-switch a {
  color: var(--muted);
  text-decoration: none;
}

.theme-switch a[aria-current="true"] {
  color: var(--ink);
  text-decoration: underline;
}

.site-header nav a,
.link-button {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover,
.link-button:hover {
  color: var(--accent);
  text-decoration: underline;
}

main {
  min-height: 60vh;
  padding: 1.5rem 0 4rem;
}

.post {
  padding: 2rem 0 2.2rem;
  border-bottom: 1px solid var(--rule);
}

.post:first-of-type { padding-top: 0.5rem; }

.post-header h1,
.post-header h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.65rem, 5vw, 2.15rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.post-header h1 a,
.post-header h2 a {
  color: var(--ink);
  text-decoration: none;
}

.post-header h1 a:hover,
.post-header h2 a:hover { color: var(--accent); }

.meta {
  margin: 0 0 1.3rem;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.015em;
}

.permalink { color: inherit; }

.prose {
  overflow-wrap: anywhere;
}

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose p { margin: 0 0 1.1em; }

.prose h1,
.prose h2,
.prose h3 {
  margin: 1.8em 0 0.55em;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.08rem; }

.prose blockquote {
  margin: 1.4em 0;
  padding: 0.1em 0 0.1em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.prose code {
  padding: 0.12em 0.3em;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--surface);
  line-height: 1.45;
}

.prose pre code { padding: 0; background: none; }
.prose img { max-width: 100%; height: auto; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }

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

.empty {
  padding: 4rem 0;
  text-align: center;
}

.empty h1 { font-size: 1.7rem; margin-bottom: 0.4rem; }
.empty p { color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
}

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

.flash {
  margin: 0 0 1.5rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.86rem;
}

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

.post-single { border-bottom: 0; padding-bottom: 1rem; }

.webmentions {
  margin-top: 2.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

.webmentions h2,
section h2 {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
}

.count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 0.3em;
  padding: 0.05em 0.4em;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
}

.webmention {
  margin: 1.2rem 0;
  padding: 1rem;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.webmention-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
}

.webmention-author img,
.avatar {
  width: 36px;
  height: 36px;
  object-fit: cover;
}

.avatar {
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.webmention h3 {
  margin: 0.7rem 0 0.25rem;
  font-size: 1rem;
}

.webmention p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.narrow { max-width: 34rem; }

.narrow h1 { letter-spacing: -0.025em; }

.rss-snippet {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre;
}

.stack {
  display: grid;
  gap: 1.2rem;
}

.stack label {
  display: grid;
  gap: 0.35rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.stack label.checkbox {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  font-weight: 400;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

textarea {
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

button,
.button {
  display: inline-block;
  width: fit-content;
  padding: 0.55rem 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover { filter: brightness(1.08); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.84rem;
}

.inline { display: inline; margin: 0; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.link-button:hover { filter: none; }
.danger { color: var(--danger); }

.wide-layout .site-header,
.wide-layout .site-footer {
  width: min(calc(100% - 2.5rem), 64rem);
}

.admin-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  width: min(calc(100% - 2.5rem), 64rem);
}

.admin-sidebar {
  position: sticky;
  top: 1.5rem;
  display: grid;
  gap: 1.2rem;
}

.admin-sidebar h1 {
  margin: 0 0 0.15rem;
  font-size: 1.6rem;
  letter-spacing: -0.025em;
}

.admin-sidebar p { margin: 0; }
.admin-sidebar .button { justify-self: start; }

.admin-nav {
  display: grid;
  gap: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.82rem;
}

.admin-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
}

.admin-nav a:hover {
  color: var(--accent);
  text-decoration: underline;
}

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

.admin-main section {
  margin: 0 0 1.5rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.admin-main section:last-child { margin-bottom: 0; }
.admin-main section h2 { margin-top: 0; }
.admin-main .flash { margin-bottom: 1.5rem; }

section { margin-bottom: 3rem; }

.admin-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.admin-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.actions { display: flex; gap: 1rem; }

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.2rem;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.facts dt {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}

.facts dd { margin: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.76rem;
}

.site-footer a { color: inherit; }

@media (max-width: 48rem) {
  .admin-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .admin-sidebar { position: static; }

  .admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
  }

  .admin-main section { padding: 1.1rem; }
}

@media (max-width: 36rem) {
  html { font-size: 16px; }
  .site-header { padding-top: 1.5rem; }
  .admin-list li { align-items: start; flex-direction: column; gap: 0.3rem; }
}
