:root {
  --page: #f1f3f6;    /* the ground the page sits on */
  --paper: #f9fafb;   /* raised surfaces: the header bar, inputs */
  --ink: #18202b;
  --quiet: #5c6776;
  --rule: #dae0e7;
  --accent: #1d5c8a;
  --on-accent: #ffffff;
  --well: #eaedf1;

  /* One serif throughout. Iowan Old Style ships on Apple devices; the rest catch
     everything else. The monospace stack stays for code. */
  --read: "Iowan Old Style", Charter, "Bitstream Charter", Palatino, "Palatino Linotype", Georgia, serif;
  --ui: var(--read);
  --code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0e131a;
    --paper: #161c24;
    --ink: #e3e7ec;
    --quiet: #8d98a6;
    --rule: #29323e;
    --accent: #82b8e0;
    --on-accent: #0e141b;
    --well: #1b222c;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.125rem/1.7 var(--read);
}

main, .head {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
/* Sticky, and it condenses on scroll: see public/site.js */
header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--page);
  border-bottom: 1px solid var(--rule);
  font-family: var(--ui);
}
.head { padding-block: 1.25rem 1rem; transition: padding 0.18s ease; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { color: var(--ink); font-weight: 700; font-size: 1.4rem; text-decoration: none; transition: font-size 0.18s ease; }
header.site nav { display: flex; align-items: center; gap: 1rem; }
header.site nav form { margin: 0; }

/* The tagline gives way to the page title as you scroll, so the bar stays one row deep */
.tagline, .context {
  margin: 0;
  overflow: hidden;
  transition: max-height 0.18s ease, opacity 0.18s ease, margin-top 0.18s ease;
}
.tagline { margin-top: 0.35rem; max-height: 3rem; color: var(--quiet); font-size: 0.9rem; }
.context {
  max-height: 0; opacity: 0; color: var(--quiet); font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

header.site.condensed .head { padding-block: 0.6rem 0.55rem; }
header.site.condensed .brand { font-size: 1.05rem; }
header.site.condensed .tagline { max-height: 0; opacity: 0; margin-top: 0; }
header.site.condensed .context { max-height: 3rem; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .head, .brand, .tagline, .context { transition: none; }
}

main { padding-block: 1.5rem 4rem; }

/* Just a closing line under the page, nothing more */
footer.site-end {
  max-width: var(--measure);
  margin-inline: auto;
  padding: 0 1.25rem 2rem;
  border-top: 1px solid var(--rule);
}


/* Buttons */
.button {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font: 600 0.95rem/1.2 var(--ui);
  text-decoration: none;
  cursor: pointer;
}
button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--quiet);
  font: 0.9rem var(--ui);
  cursor: pointer;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  cursor: pointer;
}
.icon-button:hover { opacity: 0.85; }
.icon-button svg { display: block; }

/* Post list: titles do the talking */
.entry { padding-block: 1.5rem; border-top: 1px solid var(--rule); }
.entry:first-child { border-top: 0; padding-top: 0.5rem; }
.entry h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.entry h2 a { color: var(--ink); text-decoration: none; }
.entry h2 a:hover { color: var(--accent); }
.entry p { margin: 0.5rem 0 0; color: var(--quiet); }
.empty { color: var(--quiet); }

time { display: block; margin-top: 0.3rem; font: 0.9rem var(--ui); color: var(--quiet); }

/* Single post: title matches the listing's h2, so a post reads the same size wherever it appears */
.post h1 {
  margin: 0.5rem 0 0;
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.page-title {
  margin: 0.5rem 0 1.5rem;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.post .prose { margin-top: 2rem; }

.back { margin: 0 0 1.25rem; font: 0.9rem var(--ui); }
.back a { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--quiet); text-decoration: none; }
.back a:hover { color: var(--accent); }
.back svg { width: 14px; height: 14px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--well);
  color: var(--quiet);
  font: 600 0.8rem var(--ui);
}
.archived-mark { display: inline-flex; vertical-align: middle; color: var(--quiet); }

.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3 { line-height: 1.25; margin: 2.25rem 0 0.75rem; }
.prose img { display: block; max-width: 100%; height: auto; margin: 2rem auto; border-radius: 4px; }
.prose pre { overflow-x: auto; padding: 1rem; background: var(--well); border-radius: 6px; font-size: 0.9rem; line-height: 1.5; }
.prose code { font-family: var(--code); font-size: 0.88em; }
.prose :not(pre) > code { padding: 0.1em 0.35em; background: var(--well); border-radius: 4px; }
.prose blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--quiet); }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; }
.prose th, .prose td { padding: 0.4rem 0.7rem; border: 1px solid var(--rule); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* Forms */
.stack, .editor { display: grid; gap: 1.25rem; font-family: var(--ui); }
.stack label, .editor > label { display: grid; gap: 0.4rem; font-size: 0.9rem; font-weight: 600; }

input:not([type="file"]):not([type="hidden"]), textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--ui);
}
textarea {
  min-height: 24rem;
  resize: vertical;
  font: 0.95rem/1.6 var(--code);
}
textarea.dragging { border-color: var(--accent); background: var(--well); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: -0.75rem; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.tools button, label.upload {
  padding: 0.4rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--quiet);
  font: 600 0.9rem var(--ui);
  cursor: pointer;
}
.tools button:hover { color: var(--ink); }
.tools button.active { border-color: var(--rule); color: var(--ink); }
.tools button strong, .tools button em { font-size: 1.05em; }
label.upload { border-color: var(--rule); color: var(--ink); }
label.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Sits under the editor rather than replacing it, so the writer keeps their place */
.preview {
  min-height: 6rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: 1.125rem/1.7 var(--read);
}
.preview::before {
  content: "Preview";
  display: block;
  margin-bottom: 0.9rem;
  font: 600 0.75rem var(--ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--quiet);
}

.status { min-height: 1.2em; margin: -0.5rem 0 0; color: var(--accent); font-size: 0.9rem; }
/* Action rows: a primary button beside secondary links */
.actions { display: flex; align-items: center; gap: 1.25rem; font-family: var(--ui); font-size: 0.95rem; }
.danger { color: #b3261e; }
.button.danger { background: #b3261e; color: #fff; }
@media (prefers-color-scheme: dark) {
  .danger { color: #f2b8b5; }
  .button.danger { background: #8c1d18; color: #fff; }
}

.error { color: var(--accent); font-family: var(--ui); }
.message { color: var(--quiet); }

@media (max-width: 480px) {
  body { font-size: 1.0625rem; }
  header.site { padding-block: 1rem; }
  textarea, .preview { min-height: 18rem; }
}
