/* ═══════════════════════════════════════════════════════════
   Code Swamp — the blog lives inside a skeuomorphic CRT.
   Two devices, one token set:
   · Nachtschicht (default, independent of OS preference):
     dark olive KNEIPITRON in a rainy night swamp — layered SVG
     backdrop (grain wall → rain streaks → waves), inlined in the
     shell as fixed compositor layers.
   · Tagschicht (opt-in via toggle → [data-theme="light"]):
     retro beige monitor in a misty morning swamp — same layer
     recipe with its own daylight SVG set.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Backdrop — base behind the SVG layers (deep night violet) */
  --bd-base: #120617;

  /* Ambient light on the case: night sky above, swamp below */
  --case-tint-top: rgba(156, 108, 220, 0.13);
  --case-tint-top-soft: rgba(156, 108, 220, 0.02);
  --case-tint-bottom-soft: rgba(52, 84, 38, 0.16);
  --case-tint-bottom: rgba(58, 92, 40, 0.22);
  --halo-top: 0 -14px 44px rgba(150, 100, 220, 0.13);
  --halo-bottom: 0 26px 60px rgba(8, 20, 8, 0.65);

  /* Case — dark olive plastic */
  --case-hi: #4b5346;
  --case: #383f35;
  --case-lo: #272c25;
  --case-edge: #161a15;
  --case-sheen: rgba(255, 255, 255, 0.14);
  --case-shadow: rgba(0, 0, 0, 0.65);
  --bezel-a: #23281f;
  --bezel-b: #171c16;
  --brand-ink: #5d685a;
  --brand-hi: #71806a;
  --emboss-light: rgba(255, 255, 255, 0.09);
  --btn-a: #454c41;
  --btn-b: #2a2f28;
  --btn-ink: #b9c7b2;
  --btn-base: #191d17;

  /* Screen */
  --bg: #0c130e;
  --panel: #101c14;
  --panel-glass: rgba(16, 28, 20, 0.92);
  --ink: #e8f1e6;
  --moss: #2b4a37;
  --moss-soft: #1a2e21;
  --fern: #8fb39e;
  --green: #63b04f;
  --yellow: #ffd23e;
  --glow: #a8e6b7;
  --dim-ink: #56755f;
  --link: #ffd23e;
  --link-visited: #d4b02e;
  --focus: #ffd23e;
  --highlight-bg: rgba(255, 210, 62, 0.08);
  --selection-bg: #2a2205;
  --selection-text: #ffd23e;
  --code-bg: #14251a;
  --pre-bg: #0a1a0f;
  --pre-text: #c8ddd4;
  --avatar-shadow: #1d4a2f;
  --hover-bg: rgba(99, 176, 79, 0.07);
  --h-glow: 0 0 14px rgba(255, 210, 62, 0.25);
  --wave: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%228%22%20viewBox%3D%220%200%2024%208%22%3E%3Cpath%20d%3D%22M0%204%20Q6%200%2012%204%20T24%204%22%20stroke%3D%22%232b4a37%22%20stroke-width%3D%221.5%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E');
  --scanline: rgba(0, 0, 0, 0.16);
  --reflect-1: rgba(212, 255, 226, 0.055);
  --reflect-2: rgba(255, 255, 255, 0.035);
  --glass-vignette: rgba(0, 0, 0, 0.55);

  /* Type scale */
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  --font-sans:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  /* Display face: characterful per-OS, zero bytes — SF Rounded on Apple */
  --font-display:
    ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Quicksand,
    Comfortaa, Manjari, "Arial Rounded MT", "Arial Rounded MT Bold", Calibri,
    var(--font-sans);
  /* Micro-interactions */
  --transition-fast: 80ms ease;
  --transition-base: 150ms ease;
}

/* ═══════════════════════════════════════════════════════════
   Tagschicht — beige monitor, morning mist (explicit opt-in)
   Yellow moves from text color to dark gold: as bright yellow
   it fails contrast on light ground.
   ═══════════════════════════════════════════════════════════ */

:root[data-theme="light"] {
  /* Ambient light: dusty morning sky above, pale reeds below —
     sampled from the Tagschicht backdrop SVGs */
  --case-tint-top: rgba(148, 185, 198, 0.3);
  --case-tint-top-soft: rgba(148, 185, 198, 0.06);
  --case-tint-bottom-soft: rgba(196, 208, 150, 0.28);
  --case-tint-bottom: rgba(196, 208, 150, 0.42);
  --halo-top: 0 -14px 44px rgba(140, 180, 200, 0.35);
  --halo-bottom: 0 26px 60px rgba(110, 115, 85, 0.45);

  --bd-base: hsl(34, 30%, 65%);

  --case-hi: #ece4cc;
  --case: #d9d0b5;
  --case-lo: #c1b79b;
  --case-edge: #a89d82;
  --case-sheen: rgba(255, 255, 255, 0.55);
  --case-shadow: rgba(90, 96, 74, 0.45);
  --bezel-a: #cfc6ab;
  --bezel-b: #b6ac90;
  --brand-ink: #8f8468;
  --brand-hi: #a99d7e;
  --emboss-light: rgba(255, 255, 255, 0.6);
  --btn-a: #e3dabf;
  --btn-b: #c6bc9f;
  --btn-ink: #5c543e;
  --btn-base: #93886c;

  --bg: #edf3e3;
  --panel: #dfe9d2;
  --panel-glass: rgba(223, 233, 210, 0.92);
  --ink: #17291d;
  --moss: #b9cdb0;
  --moss-soft: #d3e0c8;
  --fern: #4d6b57;
  --green: #2e7d43;
  --yellow: #8a6d00;
  --glow: #2e7d43;
  --dim-ink: #6d8272;
  --link: #1f6b35;
  --link-visited: #175327;
  --focus: #17291d;
  --highlight-bg: rgba(255, 210, 62, 0.28);
  --selection-bg: #ffd23e;
  --selection-text: #17291d;
  --code-bg: #dfe9d2;
  --pre-bg: #f6f9f0;
  --pre-text: #24382b;
  --avatar-shadow: #2e7d43;
  --hover-bg: rgba(46, 125, 67, 0.08);
  --h-glow: none;
  --wave: url('data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%228%22%20viewBox%3D%220%200%2024%208%22%3E%3Cpath%20d%3D%22M0%204%20Q6%200%2012%204%20T24%204%22%20stroke%3D%22%23a8c39a%22%20stroke-width%3D%221.5%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E');
  --scanline: rgba(60, 80, 55, 0.10);
  --reflect-1: rgba(255, 255, 255, 0.32);
  --reflect-2: rgba(255, 255, 255, 0.14);
  --glass-vignette: rgba(120, 130, 100, 0.28);
}

/* ═══════════════════════════════════════════════════════════
   Accessibility utilities
   ═══════════════════════════════════════════════════════════ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  z-index: 200;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Reset */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

/* ═══════════════════════════════════════════════════════════
   Base / backdrop — colors only
   ═══════════════════════════════════════════════════════════ */

html {
  background: var(--bd-base);
}

body {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background: var(--bd-base);
}

/* Swamp SVG layers (inlined in the shell), back to front: grain
   wall → rain streaks → waves. One set per theme, toggled by
   display. All fixed — nothing repaints on scroll; the stage
   rides above them on z-index 1. */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Rain fades out toward the waves */
.bg-flurry {
  opacity: 0.5;
  -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.9) 40%, rgba(0, 0, 0, 0) 88%);
  mask-image: linear-gradient(rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.9) 40%, rgba(0, 0, 0, 0) 88%);
}

/* Waves rise from the bottom edge; sliced, never squashed */
.bg-swamp {
  top: auto;
  height: min(52vh, 460px);
}

.bg--light {
  display: none;
}

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

:root[data-theme="light"] .bg--light {
  display: block;
}

/* The monitor is bolted to the viewport: the stage is exactly one
   screen tall and the content scrolls INSIDE the glass — the case
   never grows with long posts. */
.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  padding: 2vh 2vw 2.5vh;
  display: flex;
}

/* ═══════════════════════════════════════════════════════════
   The CRT case
   ═══════════════════════════════════════════════════════════ */

/* The monitor scales with the viewport — no fixed aspect ratio.
   Short pages fill the window (flex chain down to the screen);
   long pages grow past it and scroll as before. */
.crt {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.case {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* ambient tint (sky above, swamp below) over the plastic gradient */
  background:
    linear-gradient(var(--case-tint-top), var(--case-tint-top-soft) 26%, transparent 55%, var(--case-tint-bottom-soft) 88%, var(--case-tint-bottom)),
    linear-gradient(172deg, var(--case-hi) 0%, var(--case) 22%, var(--case-lo) 78%, var(--case-edge) 100%);
  border-radius: 30px 30px 22px 22px;
  padding: clamp(16px, 3vw, 30px) clamp(16px, 3vw, 30px) 0;
  box-shadow:
    inset 0 2px 1px var(--case-sheen),
    inset 3px 0 2px rgba(255, 255, 255, 0.04),
    inset -3px 0 3px rgba(0, 0, 0, 0.15),
    inset 0 -2px 3px rgba(0, 0, 0, 0.25),
    var(--halo-top),
    var(--halo-bottom);
}

/* vent slits on the top face */
.case::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  width: 34%;
  height: 7px;
  border-radius: 4px;
  opacity: 0.45;
  background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(0, 0, 0, 0.4) 10px 14px);
}

.bezel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--bezel-b), var(--bezel-a) 4%, var(--bezel-b) 96%, var(--bezel-a));
  border-radius: 20px;
  padding: clamp(8px, 1.6vw, 14px);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 2px rgba(255, 255, 255, 0.08);
}

.glass {
  position: relative;
  background: var(--bg);
  border-radius: 16px / 20px;
  overflow: clip;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow:
    inset 0 0 90px var(--glass-vignette),
    inset 0 0 10px rgba(0, 0, 0, 0.35);
}

/* Glass optics cover the (viewport-fixed) glass; the text scrolls
   beneath them inside the screen. */
.glass-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(120% 90% at 18% -12%, var(--reflect-1), transparent 44%),
    linear-gradient(118deg, var(--reflect-2) 0%, transparent 26%);
}

.glass-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.3;
  background: repeating-linear-gradient(transparent 0 3px, var(--scanline) 3px 4px);
}

/* ═══════════════════════════════════════════════════════════
   Screen chrome: title bar + status bar
   ═══════════════════════════════════════════════════════════ */

/* The screen fills the glass so the status bar sits at its bottom
   edge even on short pages — main stretches, footer stays down. */
.glass {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The terminal's scroll surface: bar and status stay put like real
   screen chrome, only the content pane moves. */
.screen main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--moss) transparent;
}

.screen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.4rem;
  background: var(--panel-glass);
  border-bottom: 1px solid var(--moss);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fern);
}

.screen-path {
  color: var(--fern);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.screen-path b {
  color: var(--green);
  font-weight: 400;
}

.screen-path:hover,
.screen-path:hover b {
  color: var(--yellow);
}

.screen-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 1.4rem;
  background: var(--panel-glass);
  border-top: 1px solid var(--moss);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.screen-status__links {
  display: flex;
  gap: 1rem;
}

.status-link {
  color: var(--glow);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.status-link:hover {
  color: var(--yellow);
}

.screen-status__copy {
  color: var(--dim-ink);
}

/* ═══════════════════════════════════════════════════════════
   Chin: brand, LED, hardware theme toggle
   ═══════════════════════════════════════════════════════════ */

.chin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 12px clamp(14px, 2vw, 30px) 20px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  color: var(--brand-ink);
  text-shadow: 0 1px 0 var(--emboss-light), 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

/* Toggles are progressive enhancement — dead buttons help nobody */
html.no-js .hbtn {
  display: none;
}

.hbtn {
  min-width: 30px;
  height: 26px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--btn-ink);
  padding: 0 8px;
  background: linear-gradient(var(--btn-a), var(--btn-b));
  box-shadow: inset 0 1px 0 var(--case-sheen), 0 2px 0 var(--btn-base), 0 3px 4px rgba(0, 0, 0, 0.35);
}

.hbtn:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 var(--case-sheen), 0 0 0 var(--btn-base);
}

/* The light switch: a lamp on a hardware button. Flipping to
   Tagschicht turns the light on — the button sits pressed-in
   and the bulb glows. */
.hbtn--lamp {
  font-size: 1rem;
  display: inline-grid;
  place-items: center;
}

.hbtn--lamp svg {
  display: block;
}

:root[data-theme="light"] .hbtn--lamp {
  transform: translateY(2px);
  color: #7a5c00;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.28),
    0 0 0 var(--btn-base),
    0 0 14px 3px rgba(255, 210, 62, 0.55);
}

:root[data-theme="light"] .hbtn--lamp .lamp-glass {
  fill: #ffd23e;
}

.led {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--brand-ink);
}

.led i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7be08a;
  box-shadow: 0 0 8px 2px rgba(123, 224, 138, 0.55), inset 0 -1px 1px rgba(0, 0, 0, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   Screen body / layout
   ═══════════════════════════════════════════════════════════ */

.screen-body {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 2.2rem 1.6rem 2.6rem;
}

/* ═══════════════════════════════════════════════════════════
   Homepage intro
   ═══════════════════════════════════════════════════════════ */

.home-intro {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.home-avatar-wrap {
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  background: var(--panel);
  overflow: hidden;
  border: 2px solid var(--moss);
  box-shadow: 5px 5px 0 var(--avatar-shadow);
}

.home-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-intro__text {
  padding-top: 0.25rem;
}

.home-intro__text p {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

.home-intro__text p:last-child {
  margin-bottom: 0;
  color: var(--fern);
  font-size: 0.9rem;
}

.home-intro__text strong {
  color: var(--green);
}

/* Soft wave divider between intro and posts */
.water-divider {
  height: 8px;
  margin: 2.1rem 0 1.7rem;
  background: var(--wave) repeat-x center;
}

/* ═══════════════════════════════════════════════════════════
   Post list section
   ═══════════════════════════════════════════════════════════ */

.posts-empty {
  font-size: 0.9rem;
  color: var(--fern);
  padding: 0.75rem 0;
  border-top: 1px solid var(--moss-soft);
}

.posts-section-header {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: var(--h-glow);
  margin-bottom: 0.5rem;
}

/* Spacing before a second section (e.g. Daily Notes following Posts) */
.post-list + .posts-section-header {
  margin-top: 2rem;
}

.notes-view-all {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.notes-view-all a {
  color: var(--fern);
  text-decoration: none;
}

.notes-view-all a:hover {
  color: var(--yellow);
}

.post-list {
  list-style: none;
}

.post-list__item {
  border-bottom: 1px solid var(--moss-soft);
}

/* ── Post item ── */

.post-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.95rem 0.6rem;
  text-decoration: none;
  color: var(--ink);
  border-radius: 8px;
  transition: background var(--transition-fast);
}

.post-item:hover {
  background: var(--hover-bg);
}

.post-item:hover .post-item__title {
  color: var(--yellow);
}

.post-item__title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color var(--transition-fast);
}

.post-item__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fern);
}

.post-item__meta-sep {
  opacity: 0.5;
}

.post-item__series {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}

.post-item__excerpt {
  font-size: 0.88rem;
  color: var(--fern);
  line-height: 1.5;
}

.post-item__tags {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.post-item__tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--green);
}

.post-item__tag::before {
  content: "[";
  color: var(--moss);
}

.post-item__tag::after {
  content: "]";
  color: var(--moss);
}

/* ═══════════════════════════════════════════════════════════
   Individual post — header
   ═══════════════════════════════════════════════════════════ */

.post-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  background: var(--wave) repeat-x bottom;
}

.post-back {
  display: inline-block;
  margin-bottom: 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fern);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.post-back:hover {
  color: var(--yellow);
}

.post-series {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
}

.post-header h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.post-meta {
  color: var(--fern);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.post-meta__sep {
  color: var(--moss);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.post-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--green);
}

.post-tag::before {
  content: "[";
  color: var(--moss);
}

.post-tag::after {
  content: "]";
  color: var(--moss);
}

.post-abstract {
  margin-top: 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1.05rem;
  border-left: 3px solid var(--yellow);
  background: var(--highlight-bg);
  color: var(--fern);
  font-style: italic;
  font-size: 0.93rem;
  line-height: 1.65;
  border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════
   Individual post — content
   ═══════════════════════════════════════════════════════════ */

.post-content {
  font-size: 1rem;
  line-height: 1.75;
  margin-top: 1.5rem;
}

.post-content p,
.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
}

.post-content li {
  margin-bottom: 0.3rem;
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
}

.post-content ul li::marker,
.post-content ol li::marker {
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.post-content hr {
  border: none;
  height: 8px;
  background: var(--wave) repeat-x center;
  margin: 2rem 0;
}

.post-content h2 {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 750;
  margin: 2.25rem 0 0.65rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--moss);
  position: relative;
}

.post-content h3 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  position: relative;
}

/* Heading anchors — link icon appears on hover */

.post-content .heading-anchor {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.post-content .heading-anchor::after {
  content: "🔗";
  opacity: 0;
  font-size: 0.7em;
  margin-left: 0.4em;
  vertical-align: middle;
  transition: opacity var(--transition-fast);
}

.post-content h2:hover .heading-anchor::after,
.post-content h3:hover .heading-anchor::after,
.post-content .heading-anchor:focus-visible::after {
  opacity: 1;
}

.post-content .heading-anchor:hover,
.post-content .heading-anchor:focus-visible {
  color: var(--yellow);
}

.post-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.post-content a:visited {
  color: var(--link-visited);
}

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

.post-content code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 6px;
  font-size: 0.87em;
  border: 1px solid var(--moss-soft);
}

.post-content pre:not(.shiki) {
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--moss);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.55;
}

.post-content pre:not(.shiki) code {
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
  color: inherit;
}

.post-content .shiki {
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.55;
  border: 1px solid var(--moss);
}

.post-content .shiki code {
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* Shiki ships light colors inline + dark vars; dark is our default */
:root:not([data-theme="light"]) .shiki,
:root:not([data-theme="light"]) .shiki span {
  color: var(--shiki-dark) !important;
  background-color: var(--shiki-dark-bg) !important;
}

/* Tagschicht: soften shiki's pure-white block onto the screen tone */
:root[data-theme="light"] .post-content .shiki {
  background-color: var(--pre-bg) !important;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--green);
  background: var(--hover-bg);
  color: var(--fern);
  font-style: italic;
  border-radius: 10px;
}

/* Anchor target highlight — CSS-only, works with TOC links */
.post-content > h2:target,
.post-content > h3:target {
  color: var(--yellow);
  background: var(--highlight-bg);
  padding-left: 0.5rem;
  margin-left: -0.5rem;
  border-radius: 2px;
  transition: background var(--transition-base);
}

/* Images / figures */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--moss);
  display: block;
}

.post-content figure {
  margin: 1.5rem 0;
}

.post-content figcaption {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fern);
  margin-top: 0.4rem;
  text-align: center;
}

/* Generated responsive figures (sharp pipeline) — centered */
.post-content .post-figure img {
  margin-inline: auto;
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
}

.post-content th {
  background: var(--highlight-bg);
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--yellow);
}

.post-content td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--moss-soft);
  vertical-align: top;
}

.post-content tr:last-child td {
  border-bottom: none;
}

.post-content kbd {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--moss);
  border-bottom: 2px solid var(--fern);
  padding: 0.05em 0.4em;
  border-radius: 3px;
  font-size: 0.85em;
}

/* ═══════════════════════════════════════════════════════════
   Mermaid diagrams — dark variant is the default
   ═══════════════════════════════════════════════════════════ */

.mermaid-diagram {
  margin: 1.75rem 0;
  text-align: center;
  border: 1px solid var(--moss-soft);
  border-radius: 10px;
  padding: 1.25rem 0.5rem;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.mermaid-light {
  display: none;
}

.mermaid-dark {
  display: block;
}

:root[data-theme="light"] .mermaid-light {
  display: block;
}

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

/* ═══════════════════════════════════════════════════════════
   Table of contents
   ═══════════════════════════════════════════════════════════ */

.post-toc {
  margin: 1.75rem 0;
  padding: 0.9rem 1.2rem;
  border: 1px solid var(--moss);
  font-family: var(--font-mono);
  font-size: 0.83rem;
  background: var(--panel);
  border-radius: 10px;
}

.post-toc__label {
  font-family: var(--font-display);
  color: var(--yellow);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.post-toc__list {
  list-style: decimal;
  padding-left: 1.3rem;
  margin: 0;
}

.post-toc__list li {
  margin-bottom: 0.2rem;
}

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

.post-toc__list a:hover {
  text-decoration: underline;
  color: var(--yellow);
}

/* ═══════════════════════════════════════════════════════════
   References
   ═══════════════════════════════════════════════════════════ */

.post-references {
  margin-top: 2.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--moss-soft);
}

.post-content .post-references h2 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--fern);
  margin: 0 0 0.6rem;
  border-bottom: none;
  padding-bottom: 0;
}

.post-references ol {
  padding-left: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.77rem;
  color: var(--fern);
}

.post-references li {
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.post-references a {
  color: var(--fern);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-ref-link {
  color: var(--green);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.7em;
  vertical-align: super;
}

.post-ref-link:hover {
  text-decoration: underline;
  color: var(--yellow);
}

/* ═══════════════════════════════════════════════════════════
   Responsive — the phone itself becomes the KNEIPITRON
   The case shrinks to a slim frame (10px stage + 8px case +
   5px bezel per side) and the swamp peeks through as a narrow
   seam all around. The case is viewport-fixed like on desktop,
   so bar and chin simply stay in place — no sticky hacks.
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 720px) {
  .stage {
    padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
  }

  .case {
    border-radius: 18px 18px 14px 14px;
    padding: 8px 8px 0;
    box-shadow:
      inset 0 1px 1px var(--case-sheen),
      inset 0 -1px 2px rgba(0, 0, 0, 0.25),
      0 -8px 26px rgba(150, 100, 220, 0.13),
      0 14px 34px rgba(8, 20, 8, 0.6);
  }

  :root[data-theme="light"] .case {
    box-shadow:
      inset 0 1px 1px var(--case-sheen),
      0 -8px 26px rgba(140, 180, 200, 0.3),
      0 14px 34px rgba(110, 115, 85, 0.4);
  }

  .case::before {
    display: none;
  }

  .bezel {
    padding: 5px;
    border-radius: 12px;
  }

  .glass {
    border-radius: 9px / 11px;
  }

  /* softer scanlines — readability on small pixels */
  .glass-fx::after {
    opacity: 0.22;
  }

  .screen-bar {
    padding: 0.45rem 0.9rem;
    font-size: 0.68rem;
  }

  .chin {
    padding: 8px 14px;
  }

  .screen-status__copy-extra {
    display: none;
  }

  .brand {
    font-size: 0.6rem;
    letter-spacing: 0.16em;
  }

  .hbtn {
    min-width: 38px;
    height: 30px;
  }

  .bg-swamp {
    height: min(32vh, 300px);
  }

  .screen-status {
    padding: 0.45rem 0.9rem;
    font-size: 0.66rem;
    gap: 0.35rem;
  }

  .screen-status__links {
    gap: 0.7rem;
  }

  .screen-body {
    padding: 1.5rem 1rem 2rem;
  }

  .home-intro {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-avatar-wrap {
    width: 100px;
    height: 100px;
  }

  .home-intro__text {
    padding-top: 0;
  }

  .post-item {
    padding: 0.9rem 0.35rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   Motion preferences
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .post-item,
  .post-item__title,
  .status-link,
  .screen-path,
  .hbtn,
  .post-content .heading-anchor,
  .post-back {
    transition: none;
  }
}
