:root {
  /* palette — Paper (light, default) */
  --bg: #faf9f6;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e4e1d9;
  --code-bg: #f1ede3;
  color-scheme: light;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --prose: Charter, "Iowan Old Style", Georgia, Cambria, serif;
  /* syntax tokens — github-light, warm-tuned for Paper */
  --z-fg: #24292e;  --z-bg: #fafbfc;   --z-hl-bg: #fffbdd; --z-ln: #6e7781;
  --z-comment: #6a737d; --z-blue: #005cc5; --z-purple: #6f42c1; --z-red: #d73a49;
  --z-string: #032f62;  --z-orange: #e36209; --z-green: #22863a; --z-lightblue: #0366d6;
  --z-bracket: #586069; --z-invalid: #b31d28;
  --z-deleted-bg: #ffeef0; --z-inserted-bg: #e6ffed; --z-changed-bg: #ffebda; --z-ignored-fg: #24292e;
}
/* dark — auto when the OS prefers it and the user has not forced a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0d0d0f; --fg: #e6e6e6; --muted: #8a8a8a; --rule: #262629; --code-bg: #0a0a0c;
    --z-fg: #e1e4e8; --z-bg: #24292e; --z-hl-bg: #2b3036; --z-ln: #444d56;
    --z-comment: #6a737d; --z-blue: #79b8ff; --z-purple: #b392f0; --z-red: #f97583;
    --z-string: #9ecbff; --z-orange: #ffab70; --z-green: #85e89d; --z-lightblue: #dbedff;
    --z-bracket: #d1d5da; --z-invalid: #fdaeb7;
    --z-deleted-bg: #86181d; --z-inserted-bg: #144620; --z-changed-bg: #c24e00; --z-ignored-fg: #2f363d;
  }
}
/* dark — forced by the toggle, wins over the OS */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0f; --fg: #e6e6e6; --muted: #8a8a8a; --rule: #262629; --code-bg: #0a0a0c;
  --z-fg: #e1e4e8; --z-bg: #24292e; --z-hl-bg: #2b3036; --z-ln: #444d56;
  --z-comment: #6a737d; --z-blue: #79b8ff; --z-purple: #b392f0; --z-red: #f97583;
  --z-string: #9ecbff; --z-orange: #ffab70; --z-green: #85e89d; --z-lightblue: #dbedff;
  --z-bracket: #d1d5da; --z-invalid: #fdaeb7;
  --z-deleted-bg: #86181d; --z-inserted-bg: #144620; --z-changed-bg: #c24e00; --z-ignored-fg: #2f363d;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}
a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted); }
a:hover { color: var(--muted); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
::selection { background: var(--fg); color: var(--bg); }

/* motd: Unix login banner on the homepage */
.motd { font-family: var(--mono); font-size: .85rem; line-height: 1.7; color: var(--muted); border: 0; padding: 0; margin: 0 0 1.75rem; white-space: pre-wrap; overflow-x: visible; background: none; }

/* Command echo: index-type pages show the shell command that produced them */
.cmd { color: var(--muted); font-size: .9rem; margin: 0 0 1.5rem; }
.cursor { display: inline-block; width: .55em; height: 1.05em; margin-left: .15em; vertical-align: text-bottom; background: var(--fg); animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

header { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: baseline; margin-bottom: 2.5rem; }
header .prompt { color: var(--muted); text-decoration: none; font-weight: 600; }
header nav a { margin-right: 1rem; }
header nav a:last-child { margin-right: 0; }

h1, h2, h3, h4 { font-family: var(--mono); line-height: 1.3; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
small, .meta { color: var(--muted); font-size: .85rem; }

/* Home listing (ls-style) */
.listing { margin-top: 1rem; }
.listing h2.year { color: var(--muted); font-size: .9rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.listing ul { list-style: none; margin: 0; padding: 0; }
.listing li { margin: 0; }
.listing li a { display: flex; gap: 1.25rem; align-items: baseline; text-decoration: none; padding: .3rem 0; position: relative; }
.listing li a::before { content: "›"; position: absolute; left: -1rem; color: var(--muted); opacity: 0; transition: opacity .12s ease; }
.listing li a:hover::before, .listing li a:focus-visible::before { opacity: 1; color: var(--fg); }
.listing li a:hover .title, .listing li a:focus-visible .title { text-decoration: underline; }
.listing li a:focus-visible { outline: none; }
.listing .date { color: var(--muted); flex: 0 0 4.5rem; font-variant-numeric: tabular-nums; }
.listing .title { flex: 1; }
.listing .lang { color: var(--muted); font-size: .8rem; align-self: center; }
@media (prefers-reduced-motion: reduce) { .listing li a::before { transition: none; } }

/* Post / page body: readable proportional prose */
.post-body { font-family: var(--prose); font-size: 1.08rem; line-height: 1.75; }
.post-body h1, .post-body h2, .post-body h3 { font-family: var(--mono); margin-top: 2rem; }
.post-body a { text-decoration-color: currentColor; }
.post-body img { max-width: 100%; height: auto; border: 1px solid var(--rule); }
.post-body blockquote { margin: 1.5rem 0; padding-left: 1.5rem; color: var(--muted); }
.post-body blockquote p { position: relative; }
.post-body blockquote p::before { content: ">"; position: absolute; left: -1.5rem; color: var(--muted); font-family: var(--mono); }
.post-body code { font-family: var(--mono); font-size: .9em; }
pre { font-family: var(--mono); overflow-x: auto; padding: 1rem; border: 1px solid var(--rule); background: var(--code-bg); font-size: .85rem; line-height: 1.5; }
pre code { font-size: inherit; }
/* giallo (github-dark) colors the tokens; keep our terminal-black block bg, not giallo's grey */
pre.giallo, pre.z-code { background: var(--code-bg); }

/* Tables (incl. the media log) */
table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--rule); padding: .4rem .6rem; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

/* Media filter control bar */
.filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1rem 0; font-size: .85rem; }
.filter input, .filter select { background: var(--code-bg); color: var(--fg); border: 1px solid var(--rule); font-family: var(--mono); padding: .35rem .5rem; }
.filter .rec { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); cursor: pointer; user-select: none; }
.filter #count { color: var(--muted); margin-left: auto; }

/* Prev/next post navigation */
.post-nav { display: flex; gap: 1.5rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .85rem; }
.post-nav .prev { flex: 1; }
.post-nav .next { flex: 1; text-align: right; }
.post-nav a { text-decoration: none; color: var(--muted); }
.post-nav a:hover { color: var(--fg); text-decoration: underline; }

footer { margin-top: 3rem; }
footer .social { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: 1rem 0 .75rem; font-size: .85rem; }
footer .social a { color: var(--muted); text-decoration: none; }
footer .social a:hover { color: var(--fg); text-decoration: underline; }

.theme-toggle { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-size: 1.05rem; line-height: 1; color: var(--muted); cursor: pointer; vertical-align: baseline; }
.theme-toggle:hover { color: var(--fg); }
