  /* belt-and-suspenders: never again depend on a host page to make
     [hidden] actually hide something — modals, lists, and list-tabs on
     every page rely on this holding regardless of what serves this file. */
  [hidden] { display: none !important; }

  /* ---------- tokens: light is the base set ---------- */
  :root {
    --paper:     #e4e7e1;
    --ink:       #14181a;
    --ink-soft:  #58605c;
    --rule:      #c7ccc4;
    --accent:    #1b5a4e;
    --halo:      rgba(228, 231, 225, 0.92);

    /* the fade that lets the article sit on the photo */
    --veil: linear-gradient(90deg,
      rgba(228,231,225,0)    0%,
      rgba(228,231,225,0.08) 22%,
      rgba(228,231,225,0.42) 40%,
      rgba(228,231,225,0.80) 56%,
      rgba(228,231,225,0.97) 70%,
      rgb(228,231,225)       82%);
    --veil-v: linear-gradient(180deg,
      rgba(228,231,225,0)    0%,
      rgba(228,231,225,0.10) 34%,
      rgba(228,231,225,0.55) 60%,
      rgba(228,231,225,0.92) 82%,
      rgb(228,231,225)       100%);

    /* pre-JS stand-in so the photo area is never blank */
    --photo-fallback: linear-gradient(160deg, #2a3330, #6d7a70 55%, #b9bfb4);

    --head: 76px;
    --gutter: clamp(20px, 4vw, 52px);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper:    #0f1211;
      --ink:      #e8ebe5;
      --ink-soft: #949c95;
      --rule:     #272c29;
      --accent:   #79c7b4;
      --halo:     rgba(15, 18, 17, 0.92);
      --veil: linear-gradient(90deg,
        rgba(15,18,17,0)    0%,
        rgba(15,18,17,0.08) 22%,
        rgba(15,18,17,0.44) 40%,
        rgba(15,18,17,0.82) 56%,
        rgba(15,18,17,0.97) 70%,
        rgb(15,18,17)       82%);
      --veil-v: linear-gradient(180deg,
        rgba(15,18,17,0)    0%,
        rgba(15,18,17,0.10) 34%,
        rgba(15,18,17,0.58) 60%,
        rgba(15,18,17,0.93) 82%,
        rgb(15,18,17)       100%);
      --photo-fallback: linear-gradient(160deg, #0c1210, #2f3b36 55%, #566059);
    }
  }

  :root[data-theme="dark"] {
    --paper:    #0f1211;
    --ink:      #e8ebe5;
    --ink-soft: #949c95;
    --rule:     #272c29;
    --accent:   #79c7b4;
    --halo:     rgba(15, 18, 17, 0.92);
    --veil: linear-gradient(90deg,
      rgba(15,18,17,0)    0%,
      rgba(15,18,17,0.08) 22%,
      rgba(15,18,17,0.44) 40%,
      rgba(15,18,17,0.82) 56%,
      rgba(15,18,17,0.97) 70%,
      rgb(15,18,17)       82%);
    --veil-v: linear-gradient(180deg,
      rgba(15,18,17,0)    0%,
      rgba(15,18,17,0.10) 34%,
      rgba(15,18,17,0.58) 60%,
      rgba(15,18,17,0.93) 82%,
      rgb(15,18,17)       100%);
    --photo-fallback: linear-gradient(160deg, #0c1210, #2f3b36 55%, #566059);
  }

  /* ---------- base ---------- */
  * { box-sizing: border-box; }

  html, body { height: 100%; }

  body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100svh;
    background: var(--paper);
    color: var(--ink);
    font-family: "Spectral", Georgia, "Times New Roman", serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.68;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

  /* header and footer take whatever space their content needs; main gets
     the rest — this is what actually pins a section to one screen,
     regardless of the footer's real rendered height (never hand-guessed). */
  .masthead, .footer { flex: none; }
  main { flex: 1 1 auto; min-height: 0; }

  ::selection { background: var(--accent); color: var(--paper); }

  a { color: inherit; }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 1px;
  }

  /* ---------- masthead ---------- */
  .masthead {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 10;
    height: var(--head);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem clamp(1.5rem, 4vw, 3rem);
    flex-wrap: wrap;
    padding-inline: var(--gutter);
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
  }

  /* tile-filled, muted-pine pattern tested in the type specimen —
     background-image is generated at runtime by the script at the bottom */
  .wordmark {
    font-family: "Fraunces", Didot, Georgia, serif;
    font-weight: 900;
    font-optical-sizing: auto;
    font-size: clamp(1.5rem, 2.2vw, 1.9rem);
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    background-repeat: repeat;
    background-size: 10px 10px;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  .sections {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem clamp(1.1rem, 2.4vw, 2.2rem);
  }

  .sec-link {
    font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-soft);
    padding-block: 0.35rem;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
  }

  .sec-link:hover { color: var(--ink); }

  .sec-link[aria-current="page"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  /* ---------- the spread ---------- */
  .spread {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
  }

  /* photo: full-bleed off the left edge */
  .photo {
    position: absolute;
    inset: 0 auto 0 0;
    width: 62%;
    overflow: hidden;
  }

  .photo-media {
    position: absolute;
    inset: 0;
    background-color: var(--paper);
    background-image: var(--photo-fallback);
    background-size: cover;
    background-position: center;
  }

  /* the fade — paper-colored, so it works in both themes */
  .veil {
    position: absolute;
    inset: 0;
    background: var(--veil);
    pointer-events: none;
  }

  /* article, overlapping the faded edge */
  /* .piece stays overflow:visible (the default) so the headline's negative
     margin can still bleed left into the photo, unclipped — only the body
     wrapper below (.piece-scroll) ever scrolls. */
  .piece {
    position: relative;
    z-index: 2;
    margin-left: 36%;
    width: min(44rem, 54%);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: clamp(3rem, 7vh, 6rem);
    padding-inline-end: var(--gutter);
  }

  .piece > .eyebrow,
  .piece > .headline,
  .piece > .byline,
  .piece > .embed-slot,
  .piece > .source-link,
  .piece > .list-tabs {
    flex: none;
  }

  /* a mode switcher sitting above the headline (Musing only, so far) —
     distinct from the .list-tabs instances inside .piece-scroll elsewhere,
     which switch a list, not the whole section's content shape */
  .piece > .list-tabs {
    margin: 0 0 1.8rem;
    padding-top: 0;
    border-top: none;
  }

  .source-link {
    display: inline-block;
    align-self: flex-start;
    margin-top: 1.2rem;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-decoration: none;
    color: var(--accent);
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
  }

  .source-link:hover { color: var(--ink); }

  /* holds the Spotify embed for whatever track is currently selected —
     pinned above the scroll area, so it stays put while the list below it scrolls */
  .embed-slot {
    margin-top: 1.5rem;
  }

  .embed-slot iframe {
    display: block;
    width: 100%;
    height: 152px;
    border: none;
    border-radius: 10px;
  }

  /* everything below the byline — prose/plays, caption, the "more" link —
     scrolls on its own when it doesn't fit, while eyebrow/headline/byline
     stay put and the photo never moves. */
  .piece-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-bottom: clamp(3rem, 7vh, 6rem);
  }

  .eyebrow {
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.66rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 1.4rem;
  }

  /* hangs left into the still-visible part of the photo */
  .headline {
    font-family: "Bodoni Moda", Didot, Georgia, serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-size: clamp(2.3rem, 4.6vw, 4rem);
    line-height: 1.15;
    letter-spacing: -0.012em;
    text-wrap: balance;
    margin: 0 0 1.1rem;
    margin-left: clamp(-5.5rem, -5vw, -1rem);
    text-shadow: 0 0 28px var(--halo), 0 0 64px var(--halo);
    /* defensive cap for dynamically-sourced titles (Reading entries, in
       particular — a scraped <title> tag can run long) — never lets one
       swallow the whole fixed header area. Ordinary titles never reach it. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }

  /* per-section headline voice — body (Spectral) and labels (IBM Plex Mono)
     stay constant everywhere; only the display face varies. Reading keeps
     the base rule's Bodoni Moda. See the type specimen for the comparison
     this was picked from. */
  #reading .headline {
    /* Bodoni Moda's opsz axis is tied to rendered size via `auto`, and at
       this headline's size that means thin, display-style hairlines —
       elegant in print, prone to nearly vanishing on screen, especially
       over a photo. Decoupling opsz from size and nudging the weight up a
       touch keeps the letterforms but thickens those hairlines back up. */
    font-optical-sizing: none;
    font-variation-settings: 'opsz' 18;
    font-weight: 460;
  }

  #listening .headline {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 500;
  }

  #musing .headline {
    font-family: "Petrona", Georgia, serif;
    font-weight: 600;
  }

  #tinkering .headline {
    font-family: "Rajdhani", sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: uppercase;
  }

  .byline {
    font-size: 0.95rem;
    font-style: italic;
    color: var(--ink-soft);
    margin: 0 0 2rem;
    text-shadow: 0 0 20px var(--halo);
  }

  .prose { max-width: 34em; }
  .prose p { margin: 0 0 1.15rem; }
  .prose p:last-child { margin-bottom: 0; }
  .prose em { font-style: italic; }

  /* the opening paragraph carries a little more weight */
  .prose p:first-child {
    font-size: 1.1rem;
    line-height: 1.58;
    text-shadow: 0 0 22px var(--halo);
  }

  /* one quiet caption line, in each subject's own units */
  .caption {
    max-width: 34em;
    margin: 2.6rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.71rem;
    line-height: 1.95;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
  }

  /* "Shit AI Says" — a single standalone quote, no title, no list. Italic
     signals quoted speech rather than a headline of your own. */
  .ai-quote {
    margin: 0;
    max-width: 34em;
    font-family: "Petrona", Georgia, serif; /* same family as #musing .headline, a touch lighter/smaller */
    font-weight: 500;
    font-size: clamp(1.3rem, 2.2vw, 1.85rem);
    line-height: 1.4;
    text-wrap: balance;
    color: var(--ink);
  }

  .quote-attribution {
    margin: 1.4rem 0 0;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .quote-body {
    transition: opacity 0.25s ease;
  }

  .quote-body.is-fading {
    opacity: 0;
  }

  .quote-nav {
    display: flex;
    gap: 2rem;
    margin-top: 2.6rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
  }

  .quote-nav .more { margin-top: 0; }

  /* ---------- Observing: a grid of real photos, dealt a page at a time ----
     Unlike every other section, .spread's photo+piece split doesn't apply
     here — the grid fills the whole content area instead, so most of
     .spread's rules are overridden below. Browsing is Previous/Next only
     (no scroll-hijacking): each click deals a freshly-positioned page of up
     to 12 photos from one shuffled pass over the whole library, the same
     shuffle/reshuffle-on-wraparound pattern as "Shit AI Says". */
  #observing {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 1.6rem;
    padding: clamp(1.5rem, 5vh, 3rem) var(--gutter);
  }

  .observing-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: clamp(0.2rem, 0.5vw, 0.4rem);
    perspective: 1200px;
  }

  .photo-tile {
    position: relative;
    overflow: hidden;
    border-radius: 3px;
    background: var(--rule);
  }

  .photo-tile.is-empty { visibility: hidden; }

  /* a real two-sided flip — .tile-inner is the card that rotates; each face
     is pinned to one side of it (backface-visibility hides whichever face
     is turned away) so turning past 90° reveals the other face's own
     content instead of mirroring the same image or springing back the way
     it came. Each tile's own transition-delay (set inline, staggered by
     grid position) turns one flip into a small wave across the grid rather
     than all 12 tiles turning over in lockstep. */
  .tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.36s ease;
    transform-style: preserve-3d;
  }

  @media (prefers-reduced-motion: reduce) {
    .tile-inner { transition: none; }
  }

  .tile-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
  }

  .tile-face-b { transform: rotateY(180deg); }

  .photo-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
  }

  .observing-nav {
    flex: none;
    display: flex;
    gap: 2rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
  }

  .observing-nav .more { margin-top: 0; }

  .lightbox {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 5vw, 4rem);
    background: rgba(0, 0, 0, 0.82);
  }

  .lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 2px;
  }

  .lightbox-close {
    position: absolute;
    top: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    width: 2.2rem;
    height: 2.2rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
  }

  .lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

  /* ---------- contact modal ---------- */
  .modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 5vw, 4rem);
    background: rgba(0, 0, 0, 0.5);
  }

  .modal-panel {
    position: relative;
    width: min(30rem, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: clamp(1.6rem, 4vw, 2.4rem);
  }

  .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: var(--rule);
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
  }

  .modal-close:hover { background: var(--accent); color: var(--paper); }

  .modal-title {
    font-family: "Bodoni Moda", Didot, Georgia, serif;
    font-weight: 500;
    font-size: 1.5rem;
    margin: 0 0 1.6rem;
  }

  .modal-field {
    display: block;
    margin-bottom: 1.1rem;
  }

  .modal-field > span {
    display: block;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
  }

  .modal-field input,
  .modal-field textarea {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    padding: 0.6rem 0.7rem;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 3px;
    color: var(--ink);
    resize: vertical;
  }

  .modal-field input:focus,
  .modal-field textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .cf-turnstile { margin-bottom: 1.1rem; }

  .modal-submit {
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--accent);
    border: none;
    border-radius: 3px;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
  }

  .modal-submit:hover { opacity: 0.88; }
  .modal-submit:disabled { opacity: 0.5; cursor: default; }

  .modal-status {
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.76rem;
    margin: 1rem 0 0;
  }

  .modal-status.is-error { color: #b23b3b; }
  .modal-status.is-success { color: var(--accent); }

  /* recent-plays list — stands in for .prose when live Spotify data loads */
  /* tabs own the hairline that separates the fixed header (and the embed
     player) from the scrollable list below — .plays no longer needs its own */
  .list-tabs {
    display: flex;
    gap: 1.5rem;
    margin: 2rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
  }

  /* non-interactive sibling of .list-tabs, for lists that don't switch views */
  .list-label {
    margin: 2rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .list-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    padding: 0 0 0.35rem;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-soft);
    cursor: pointer;
  }

  .list-tab:hover { color: var(--ink); }

  /* aria-pressed is for real toggle buttons (Reading/Listening's tabs);
     aria-current="page" is for the My Writing / Shit AI Says pair, which
     are really just links between two pages, not a button pair — same
     visual treatment, different (and each individually valid) ARIA attribute. */
  .list-tab[aria-pressed="true"],
  .list-tab[aria-current="page"] {
    color: var(--ink);
    border-bottom-color: var(--accent);
  }

  .plays {
    list-style: none;
    max-width: 34em;
    margin: 1.25rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
  }

  .plays li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.25rem;
  }

  .plays .track-link {
    min-width: 0;
    text-decoration: none;
    color: var(--ink);
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid transparent;
    cursor: pointer; /* harmless on Listening's <a> (already pointer); needed
      for Musing/Tinkering/Reading's plain <span> rows, which promote the
      clicked entry to hero instead of linking anywhere */
  }

  .plays .track-link:hover { color: var(--accent); }

  .plays li.is-active .track-link {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  .plays .artist { color: var(--ink-soft); }

  .plays time,
  .plays .meta {
    flex: none;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.82rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
  }

  .more {
    display: inline-block;
    margin-top: 2.2rem;
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-decoration: none;
    color: var(--accent);
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
  }

  .more:hover { color: var(--ink); }

  /* ---------- footer ---------- */
  .footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.6rem 2rem;
    padding: 1.4rem var(--gutter) calc(1.4rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--rule);
    font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .footer a { text-decoration: none; border-bottom: 1px solid var(--rule); }
  .footer a:hover { color: var(--ink); }

  @media (prefers-reduced-motion: reduce) {
    .quote-body { transition: none; }
  }

  /* ---------- stacked, at phone width ---------- */
  @media (max-width: 980px) {
    :root { --head: auto; }

    body { display: block; min-height: 0; }
    main { flex: none; }

    .masthead {
      position: static;
      height: auto;
      padding-block: 1rem;
    }

    /* five links' worth of letter-spaced, uppercase text sits right at the
       edge of fitting on one row at phone widths with the desktop gap —
       tightening it here gives wrapping real room instead of a coin-flip */
    .sections { flex-basis: 100%; gap: 0.3rem 0.9rem; }

    .spread {
      display: block;
      height: auto;
    }

    .photo {
      position: relative;
      inset: auto;
      width: 100%;
      aspect-ratio: 5 / 4;
      max-width: 100%;
    }

    .veil { background: var(--veil-v); }

    .piece {
      display: block;
      margin-left: 0;
      width: auto;
      max-width: 44rem;
      height: auto;
      margin-top: -4.5rem;
      padding-inline: var(--gutter);
      padding-top: 0;
    }

    .piece-scroll {
      overflow-y: visible;
      padding-bottom: 3.5rem;
    }

    .headline { margin-left: 0; }

    #observing {
      display: block;
      height: auto;
      padding: 1.5rem var(--gutter) 3rem;
    }

    .observing-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      grid-template-rows: none;
      gap: 0.3rem;
    }

    .photo-tile { aspect-ratio: 1; }
  }
