/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #f5efe2;
  --parchment: #ece4d1;
  --parchment-dark: #ddd2b9;
  --sage: #8e8c5b;
  --sage-light: #c8c79a;
  --sage-lighter: #e2e1c5;
  --sage-dark: #5e5c30;
  --moss: #3c391a;
  --ink: #2d2618;
  --ink-light: #5a5040;
  --ink-muted: #8a7e6a;
  --border: #cfc7b3;
  --border-light: #e1dbc7;
  --accent: #884a3a;
  --highlight: rgba(142, 140, 91, 0.32);
  --sidebar-width: 20%;
  --sidebar-content-max: 260px;
  /* Dates, archive rails, scoped meta — Alegreya Sans reads smaller than Karla at equal px */
  --font-ui: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ui-size-rail: 12.5px;
  --font-ui-size-secondary: 14px;
  --font-ui-size-meta: 15px;
  --font-ui-size-archive-year: 18px;
}

/* Dark mode — deep warm-walnut ink (#1f1810).
   Same parchment family as light mode, just inverted: warm walnut paper
   in daylight, deep walnut ink at night. Stays clear of pure black to
   avoid halation while feeling more lamp-lit. */
html[data-theme="dark"] {
  --cream: #1f1810;
  --parchment: #2c2517;
  --parchment-dark: #36301e;
  --sage: #a8a572;
  --sage-light: #c8c79a;
  --sage-lighter: #2c2c1a;
  --sage-dark: #c8c79a;
  --moss: #e8e6cd;
  --ink: #ece6d3;
  --ink-light: #bdb6a3;
  --ink-muted: #8a8270;
  --border: #3a3322;
  --border-light: #2c2517;
  --accent: #d6a08f;
  --highlight: rgba(168, 165, 114, 0.34);
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
  overflow-x: clip;
  /* Reserve scrollbar gutter at all times so short pages (Tags, Archive,
     About) don't gain ~15px of viewport width that the sidebar's
     percentage width would expand into. */
  scrollbar-gutter: stable;
  /* WebKit / Chrome mobile: no default blue tap flash before navigation */
  -webkit-tap-highlight-color: transparent;
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: 'Spectral', serif;
  /* Match language-blog markdown: 18px < lg, 18.5px lg+ */
  font-size: 18px;
  line-height: 1.75;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* iOS paint stability (see language-blog global.css) */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@media (min-width: 1024px) {
  body {
    font-size: 18.5px;
  }
}

/* ── Theme transition (View Transitions API) ──────────────────
   The whole viewport snapshots into a single layer and reveals
   the new state with one uniform clip-path sweep, so sidebar
   and main content always change together.
   - Going to dark: sweeps down from the top.
   - Going to light: sweeps up from the bottom. */
@keyframes theme-reveal {
  from {
    clip-path: inset(var(--theme-reveal-from));
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

html[data-theme="dark"] {
  --theme-reveal-from: 0 0 100% 0;
}
html:not([data-theme="dark"]) {
  --theme-reveal-from: 100% 0 0 0;
}

::view-transition-old(root) {
  z-index: 1;
  animation: none;
}
::view-transition-new(root) {
  z-index: 2;
  clip-path: inset(0 0 0 0);
  animation: theme-reveal 0.7s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* Match text selection to sidebar nav link hover bar (--highlight) */
::selection {
  background-color: var(--highlight);
  color: var(--ink);
}
::-moz-selection {
  background-color: var(--highlight);
  color: var(--ink);
}

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  max-width: 1120px;
  margin: 0 auto;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--cream);
  overflow: hidden;
}

.sidebar-inner {
  padding: 2.5rem 1.75rem;
  max-width: var(--sidebar-content-max);
  margin-left: auto;
  margin-right: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  text-align: right;
}

/* Portrait → About: biased downward in space above the footer (asymmetric flex gaps) */
.sidebar-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-main-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-main-gap {
  min-height: 0;
}

/* More space above the cluster than below → block sits a bit below true center */
.sidebar-main-gap--before {
  flex: 3 1 0;
}

.sidebar-main-gap--after {
  flex: 1 1 0;
}

.sidebar-main-cluster {
  flex: 0 0 auto;
}

/* Avatar / photo (wrapped by .sidebar-photo-link → home) */
a.sidebar-photo-link {
  display: block;
  margin-bottom: 1.25rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.sidebar-photo-link:hover,
a.sidebar-photo-link:active {
  text-decoration: none;
  opacity: 1;
}
a.sidebar-photo-link:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 3px;
  border-radius: 4px;
}

.sidebar-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--sage-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-photo img,
.sidebar-portrait-img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
}

.avatar-placeholder {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0.5;
}

/* Sidebar text */
.sidebar-title {
  font-family: 'Spectral SC', serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--moss);
  margin-bottom: 0.4rem;
}

/* Home link: same look as plain text; no hover / active color shift */
a.sidebar-title {
  display: block;
  cursor: pointer;
}
a.sidebar-title:hover,
a.sidebar-title:active {
  color: var(--moss);
  text-decoration: none;
}
a.sidebar-title:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 3px;
}

.sidebar-subtitle {
  font-size: 14px;
  font-style: italic;
  color: var(--ink-light);
  line-height: 1.55;
  margin-bottom: 2rem;
}

/* Theme toggle — desktop: directly under nav inside cluster; flex gap sits below it.
   Mobile: pinned upper-right of masthead (see mobile media query). */
.theme-toggle-wrap {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: 0;
  margin-bottom: 0;
}

@media (min-width: 769px) {
  .theme-toggle-wrap {
    margin-top: 1.5rem;
  }
}

.theme-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 0.35rem;
  margin: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-light);
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

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

.theme-toggle:active {
  transform: scale(0.92);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Icon swap: show crescent in light, sun in dark */
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0;
  align-items: flex-end;
}

.nav-link {
  position: relative;
  display: inline-block;
  isolation: isolate;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  padding: 0.2rem 0;
  transition: color 0.15s;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0.85em;
  height: 0.55em;
  width: 100%;
  background: var(--highlight);
  z-index: -1;
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

.nav-link:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.nav-link:hover {
  color: var(--moss);
}

/* Tap / press: snap highlight to full width. A 0.3s scale animation never
   finishes on mobile because :active ends as soon as navigation starts. */
.nav-link:active::after {
  transform: scaleX(1);
  transform-origin: bottom left;
  transition-duration: 0s;
}

.nav-link:active {
  color: var(--moss);
}

/* Current section (see base.njk + is*Nav filters) — same bar as hover. */
.nav-link.active::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.nav-link.active {
  color: var(--moss);
}

.nav-link.active:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.nav-link.active:hover {
  color: var(--moss);
}

/* Link footer: sits under .sidebar-main on desktop; grid "foot" on mobile */
.sidebar-bottom {
  flex-shrink: 0;
}

/* Footer links + copyright (theme lives in .sidebar-main) */
.sidebar-footer {
  padding-top: 1.5rem;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  line-height: 1.7;
}

.sidebar-footer-links {
  margin-bottom: 0.5rem;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-footer-links a {
  position: relative;
  display: inline-block;
  isolation: isolate;
  color: var(--ink-light);
  transition: color 0.15s;
}

.sidebar-footer-links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0.5em;
  height: 0.55em;
  width: 100%;
  background: var(--highlight);
  z-index: -1;
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

.sidebar-footer-links a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.sidebar-footer-links a:hover {
  color: var(--moss);
}

.sidebar-footer-links a:active::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.sidebar-footer-links a:active {
  color: var(--moss);
}

/* ── Main ─────────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
}

/* ── Feed (homepage) ──────────────────────────────────────── */
.feed {
  max-width: 680px;
  margin: 0 auto;
  padding: 3.5rem 2.5rem;
}

/* Date groups */
.date-group {
  margin-bottom: 3.5rem;
}

.date-label {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-rail);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

a.date-label--link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

a.date-label--link:hover {
  color: var(--moss);
}

a.date-label--link:active {
  color: var(--moss);
}

/* Entry card */
.entry {
  margin-bottom: 2.25rem;
  padding-bottom: 2.25rem;
  border-bottom: 1px solid var(--border-light);
}

.entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.entry-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.entry-time {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-rail);
  letter-spacing: 0.14em;
  color: var(--ink-light);
  font-variant-numeric: tabular-nums;
}

.entry-date-link {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-rail);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-light);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: color 0.15s;
}

.entry-date-link:hover {
  color: var(--moss);
}

.entry-date-link:active {
  color: var(--moss);
}

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

.entry-tags,
.single-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 2.25rem;
  margin-bottom: 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.entry-tag {
  font-size: 13.5px;
  font-style: italic;
  color: var(--sage-dark);
  transition: color 0.15s;
}

.entry-tag:hover {
  color: var(--moss);
  text-decoration: underline;
}

.entry-tag:active {
  color: var(--moss);
  text-decoration: underline;
}

/* Entry body (rendered markdown) — sizes track language-blog .post-body-font */
.entry-body {
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  font-weight: 400;
}

@media (min-width: 1024px) {
  .entry-body {
    font-size: 18.5px;
    line-height: 1.8;
  }
}

.entry-body p { margin-bottom: 0.85em; }
.entry-body p:last-child { margin-bottom: 0; }
.entry-body em { font-style: italic; color: var(--ink); }
.entry-body strong { font-weight: 600; color: var(--ink); }
.entry-body a { color: var(--sage-dark); text-decoration: underline; text-underline-offset: 2px; }
.entry-body a:hover { color: var(--moss); }
.entry-body a:active { color: var(--moss); }
.entry-body ul, .entry-body ol { margin: 0.75em 0 0.75em 1.4em; }
.entry-body li { margin-bottom: 0.3em; }
.entry-body blockquote {
  border-left: 2px solid var(--sage-light);
  margin: 1em 0;
  padding: 0.2em 1em;
  color: var(--ink-muted);
  font-style: italic;
}
.entry-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}
.entry-body code {
  font-size: 0.88em;
  background: var(--parchment);
  padding: 1px 5px;
  border-radius: 2px;
}
.entry-body h2, .entry-body h3, .entry-body h4 {
  font-weight: 500;
  margin: 1.2em 0 0.4em;
  color: var(--ink);
}

/* Media attachments */
.entry-media {
  margin-top: 1.25rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.entry-media img,
.entry-media video {
  width: 100%;
  display: block;
}

.entry-media figcaption {
  font-size: 14px;
  font-style: italic;
  color: var(--ink-light);
  padding: 0.6rem 0.9rem;
  background: var(--parchment);
  border-top: 1px solid var(--border-light);
}

.entry-media.audio-wrap {
  background: var(--parchment);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.entry-media.audio-wrap audio {
  flex: 1;
  min-width: 200px;
  height: 32px;
}

.audio-icon {
  color: var(--sage);
  flex-shrink: 0;
}

.audio-label {
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-light);
  width: 100%;
  margin-top: 0.25rem;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pagination-link {
  color: var(--moss);
  transition: opacity 0.15s;
}

.pagination-link:hover { opacity: 0.6; }

.pagination-link:active { opacity: 0.6; }
.pagination-info { color: var(--ink-muted); }

/* ── Inner pages (Tags, Archive) ──────────────────────────── */
.inner-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 3.5rem 2.5rem;
}

.page-title {
  font-family: 'Spectral SC', serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--moss);
  margin-bottom: 2.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* Tags index page */
.all-tags-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.35rem;
}

.all-tags-item {
  margin: 0;
}

.all-tags-link {
  font-size: 18px;
  font-style: italic;
  color: var(--sage-dark);
  transition: color 0.15s;
}

.all-tags-link:hover {
  color: var(--moss);
  text-decoration: underline;
}

.all-tags-link:active {
  color: var(--moss);
  text-decoration: underline;
}

/* Individual tag page */
.tag-page-title {
  margin-bottom: 0.25rem;
}

.tag-page-hash {
  color: var(--sage);
  font-style: italic;
  font-weight: 300;
}

.tag-page-count {
  font-size: var(--font-ui-size-meta);
  font-style: italic;
  color: var(--ink-light);
}

.feed-scope-header .tag-page-count {
  margin-bottom: 0;
}

/* Tags page (kept for tag-section if needed) */
.tag-section {
  margin-bottom: 2.75rem;
  scroll-margin-top: 2rem;
}

.tag-heading {
  font-size: 17px;
  font-style: italic;
  color: var(--sage-dark);
  margin-bottom: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.tag-entry-list {
  list-style: none;
}

.tag-entry-item {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-light);
}

.tag-entry-item:last-child { border-bottom: none; }

.tag-entry-date {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-secondary);
  color: var(--ink-muted);
  min-width: 108px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.tag-entry-name {
  font-size: 17.5px;
  color: var(--ink);
  transition: color 0.15s;
}

.tag-entry-name:hover { color: var(--moss); }

/* Scoped feed (month, day, tag) */
.feed--scoped .feed-scope-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-light);
}

.feed--scoped .feed-scope-header .back-link {
  margin-bottom: 1.25rem;
}

.feed--month .feed-scope-header {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 1.75rem;
}

.feed-scope-title {
  font-family: 'Spectral SC', serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--moss);
  line-height: 1.25;
  margin-bottom: 0.35rem;
}

.feed-scope-meta {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-meta);
  font-style: italic;
  color: var(--ink-light);
  margin: 0;
}

/* Archive page (by year → months) */
.archive-year-block {
  margin-bottom: 2.75rem;
}

.archive-year-heading {
  font-family: var(--font-ui);
  margin-bottom: 0.85rem;
  font-size: var(--font-ui-size-archive-year);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink);
}

/* Two-column archive rows: label | (count), lining figures for real “1” not “I” */
.archive-row-link {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
}

.archive-row-label {
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1;
}

.archive-row-count {
  font-family: var(--font-ui);
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1;
  color: var(--ink-muted);
  font-weight: 400;
  text-align: right;
  min-width: 3.25ch;
}

.archive-row-count--title {
  font-size: 0.88em;
}

h1.page-title.page-title--archive-row {
  font-family: var(--font-ui);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
}

h1.page-title .archive-row-count--title {
  font-size: 0.68em;
  align-self: baseline;
}

.archive-month-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Nest months under their year on the main Archive page */
.archive-year-block .archive-month-list {
  margin-top: 0.15rem;
  margin-left: 0.2rem;
  padding-left: 1.35rem;
}

.archive-month-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-light);
}

.archive-month-row:last-child {
  border-bottom: none;
}

.archive-month-link {
  font-family: 'Spectral SC', serif;
  font-size: 17.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s;
}

.archive-month-link:hover {
  color: var(--moss);
}

.archive-month-link:active {
  color: var(--moss);
}

.archive-year-months {
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-year-month-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-light);
}

.archive-year-month-row:last-child {
  border-bottom: none;
}

.archive-year-month-link {
  font-family: 'Spectral SC', serif;
  font-size: 17.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.15s;
}

.archive-year-month-link:hover {
  color: var(--moss);
}

.archive-year-month-link:active {
  color: var(--moss);
}

/* ── About page ───────────────────────────────────────────── */
.about-body {
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  font-weight: 400;
  max-width: 560px;
}

@media (min-width: 1024px) {
  .about-body {
    font-size: 18.5px;
    line-height: 1.8;
  }
}

.about-body p { margin-bottom: 1.1em; }
.about-body p:last-child { margin-bottom: 0; }
.about-body a { color: var(--sage-dark); text-decoration: underline; text-underline-offset: 2px; }
.about-body a:hover { color: var(--moss); }

.about-body a:active { color: var(--moss); }

/* ── Single post ──────────────────────────────────────────── */
.single-post {
  max-width: 680px;
  margin: 0 auto;
  padding: 3.5rem 2.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  margin-bottom: 2.75rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--moss); }

.back-link:active { color: var(--moss); }

.single-meta {
  margin-bottom: 0.4rem;
}

.single-date {
  font-family: var(--font-ui);
  font-size: var(--font-ui-size-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
}

.single-title {
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 1.75rem;
}

/* Tag row after body/media: see `.entry-tags` shared with feed cards. */

/* ── Media safety net (applies at all widths) ──────────────── */
.entry-body img,
.entry-body video,
.entry-media img,
.entry-media video {
  max-width: 100%;
  height: auto;
}

.entry-body pre {
  overflow-x: auto;
  max-width: 100%;
  background: var(--parchment);
  padding: 0.85rem 1rem;
  border-radius: 4px;
  font-size: 0.85em;
  line-height: 1.55;
}

.entry-body pre code {
  background: transparent;
  padding: 0;
  font-size: 1em;
}

.entry-body a,
.about-body a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ── Tablet ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 28%;
  }

  .feed,
  .inner-page,
  .single-post {
    padding: 3rem 2rem;
  }
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --font-ui-size-rail: 13.5px;
    --font-ui-size-secondary: 15px;
    --font-ui-size-meta: 16px;
    --font-ui-size-archive-year: 19px;
  }

  /* Masthead (photo / title / nav / theme) → article → link footer only */
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "masthead"
      "main"
      "foot";
    max-width: 100%;
    min-height: 100vh;
  }

  .sidebar {
    display: contents;
    width: auto;
    min-width: 0;
    height: auto;
    position: static;
    background: transparent;
    overflow: visible;
  }

  .sidebar-inner {
    display: contents;
    padding: 0;
    max-width: none;
    min-height: 0;
    text-align: left;
    margin-left: 0;
    margin-right: 0;
  }

  .sidebar-main {
    grid-area: masthead;
    flex: none;
    position: relative;
    padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
    padding-bottom: 1rem;
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  }

  .sidebar-main-body {
    flex: 0 1 auto;
  }

  .sidebar-main-gap--before,
  .sidebar-main-gap--after {
    display: none;
  }

  .sidebar-bottom {
    grid-area: foot;
    flex-shrink: 0;
    padding-top: 0;
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  }

  .main {
    grid-area: main;
    min-width: 0;
    min-height: 0;
  }

  /* annemuses-style: moon/sun in the upper-right of the masthead */
  .theme-toggle-wrap {
    position: absolute;
    top: max(1.5rem, env(safe-area-inset-top, 0px));
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    margin-top: 0;
    margin-bottom: 0;
    justify-content: flex-end;
    z-index: 2;
  }

  /* Keep long title / nav from sliding under the pinned toggle */
  .sidebar-main-cluster {
    padding-right: 2.75rem;
  }

  /* Show portrait on small screens (was display:none — looked like a broken/missing photo). */
  .sidebar-main-cluster .sidebar-photo-link {
    align-self: flex-start;
    width: fit-content;
    max-width: 100%;
  }

  .sidebar-photo {
    display: flex;
    width: 96px;
    max-width: 96px;
    margin-left: 0;
    margin-right: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
  }

  /* Slightly larger tap target on mobile */
  .theme-toggle {
    width: 34px;
    height: 34px;
    padding: 0.4rem;
    touch-action: manipulation;
  }

  .theme-toggle svg {
    width: 20px;
    height: 20px;
  }

  .nav-link {
    font-size: 14.5px;
  }

  .back-link {
    font-size: 15px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-start;
  }

  .pagination {
    font-size: 14.5px;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }

  .entry-media.audio-wrap audio {
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
  }

  .sidebar-title,
  a.sidebar-title {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .page-title,
  .feed-scope-title,
  .single-title {
    overflow-wrap: anywhere;
  }

  .sidebar-footer {
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
    font-size: 12.5px;
  }

  .sidebar-footer-links {
    white-space: normal;
    font-size: 12.5px;
  }

  .feed,
  .inner-page,
  .single-post {
    padding-top: 2rem;
    padding-bottom: 2rem;
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
    margin-left: 0;
  }

  .single-title {
    font-size: 26px;
    line-height: 1.3;
  }

  .page-title {
    font-size: 22px;
  }

  .feed-scope-title {
    font-size: 22px;
  }

  /* Tag-page rows: let date and title stack gracefully when tight */
  .tag-entry-item {
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
  }

  .tag-entry-date {
    min-width: 0;
  }

  /* Single post: match language-blog — less header chrome on small screens so
     the article reaches the viewport sooner (nav returns from lg / desktop).
     Theme toggle is pinned upper-right on mobile via rules above. */
  body.single-post .sidebar-nav,
  body.single-post .sidebar-subtitle {
    display: none;
  }
}

/* ── Narrow phones ────────────────────────────────────────── */
@media (max-width: 380px) {
  :root {
    --font-ui-size-rail: 14px;
    --font-ui-size-secondary: 15.5px;
    --font-ui-size-meta: 17px;
    --font-ui-size-archive-year: 19.5px;
  }

  .sidebar-main {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .sidebar-bottom {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .feed,
  .inner-page,
  .single-post {
    padding-top: 1.75rem;
    padding-bottom: 1.75rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .single-title {
    font-size: 23px;
  }

  .nav-link {
    font-size: 15px;
  }

  .pagination {
    font-size: 15px;
  }

  .back-link {
    font-size: 15.5px;
  }

  .sidebar-footer,
  .sidebar-footer-links {
    font-size: 13px;
  }
}
