:root {
  /* ---- base hues: channels only, so every tint/shade of a colour comes
     from one source. Compose with rgba(var(--x-rgb), alpha) at each site
     rather than writing the RGB triplet out again.
     Palette matches the v1 site (styles.css): indigo-navy surfaces, cool
     white text, violet/pink/teal accent trio. ---- */
  --ink-rgb: 10, 10, 30;            /* shadows, depth, dimming overlays */
  --glass-rgb: 255, 255, 255;       /* glass highlights, borders, sheens */
  --accent-rgb: 139, 123, 255;      /* v1's violet accent */
  --mist-rgb: 166, 169, 200;        /* v1's muted lavender-grey text */
  --frost-rgb: 200, 225, 255;       /* cool blue-white glass-shelf tint */
  --sky-rgb: 87, 224, 196;          /* v1's teal accent, page backdrop glow */
  --panel-rgb: 28, 31, 62;          /* v1's surface colour, panel glass fill */
  --accent-2-rgb: 255, 123, 176;    /* pink accent, channel form for tints */

  /* ---- surfaces ---- */
  --bg-base: #0f1120;
  --bg-deep: #161832;
  --surface-ink: #1c1f3e;           /* notepad paper, matches v1 surface */
  --panel-bg: rgba(var(--panel-rgb), 0.6);

  /* ---- text ---- */
  --text-light: #f1f2fb;
  --text-muted: rgba(var(--mist-rgb), 0.55);

  /* ---- accent ---- */
  --accent: #8b7bff;                /* headings, tags, focus rings */
  --accent-2: #ff7bb0;              /* buttons (CTA, close) */
  --accent-hover: #ffa8cc;          /* button hover state */
  --accent-ink: #0f1120;            /* dark text set on top of an accent button */
  --accent-soft: rgba(var(--accent-rgb), 0.16);

  /* ---- glass tones reused across the book/newspaper/shelf materials ---- */
  --glass-border: rgba(var(--glass-rgb), 0.16);
  --glass-highlight: rgba(var(--glass-rgb), 0.22);
  --glass-soft: rgba(var(--glass-rgb), 0.14);
  --glass-faint: rgba(var(--glass-rgb), 0.08);

  /* ---- fonts: a display serif for headings, a bolder display serif for
     book/story/blog titles (they need to hold up bold+uppercase at small
     sizes), and a sans for body copy, labels, and UI chrome. ---- */
  --serif: "Cormorant Garamond", Georgia, serif;
  --serif-title: "Playfair Display", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  color: var(--text-light);
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(var(--accent-rgb), 0.08), transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 30%, rgba(var(--sky-rgb), 0.05), transparent 60%),
    linear-gradient(180deg, var(--bg-base) 0%, var(--bg-deep) 100%);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header: centered site name + bookshelf heading ---------- */
.site-header {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  padding: clamp(0.6rem, 2vh, 1.2rem) 1rem clamp(0.3rem, 1vh, 0.6rem);
}

.site-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.site-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 4.6vh, 2.6rem);
  color: var(--text-light);
  text-decoration: none;
  letter-spacing: 0.3px;
}

.site-title span {
  color: var(--accent);
}

.site-title:hover {
  color: var(--accent);
}

.site-title:hover span {
  color: var(--text-light);
}

/* Only shown on mobile, where the detail panel is a popup rather than
   always-docked, so it needs an explicit way to open the site intro. */
.info-toggle {
  display: none;
  appearance: none;
  border: 1px solid var(--glass-border);
  background: var(--glass-faint);
  color: var(--text-light);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.info-toggle svg {
  width: 18px;
  height: 18px;
}

.info-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.info-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);
}

/* Nudges first-time visitors to open the intro; stops for good once
   they've clicked it (see bookshelf.js, which toggles this class and
   remembers the dismissal in localStorage). */
.info-toggle.is-pulsing {
  border-color: var(--accent);
  color: var(--accent);
  animation: infoPulse 1.8s ease-out infinite;
}

@keyframes infoPulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ---------- Mail me: header widget offering a choice of webmail ---------- */
.mail-menu {
  position: absolute;
  top: clamp(0.6rem, 2vh, 1.2rem);
  right: clamp(0.8rem, 3vw, 1.6rem);
  z-index: 40;
}

.mail-toggle {
  appearance: none;
  border: 1px solid var(--glass-border);
  background: var(--glass-faint);
  color: var(--text-light);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mail-toggle svg {
  width: 15px;
  height: 15px;
}

.mail-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mail-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);
}

.mail-menu.is-open .mail-toggle {
  border-color: var(--accent);
  color: var(--accent);
}

.mail-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: max-content;
  min-width: 168px;
  padding: 0.6rem;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--bg-base);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 12px 28px rgba(var(--ink-rgb), 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.mail-panel[hidden] {
  display: none;
}

.mail-panel-title {
  margin: 0.1rem 0.4rem 0.4rem;
  font-family: var(--sans);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.mail-option {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-light);
  text-decoration: none;
  white-space: nowrap;
}

.mail-option:hover,
.mail-option:focus-visible {
  background: var(--glass-faint);
  color: var(--accent);
  outline: none;
}

.shelf-heading {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 2.4vh, 1.4rem);
  color: var(--text-muted);
  margin: 0.3rem 0 0;
}

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: 0.9rem 1.5rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  z-index: 30;
}

/* ---------- Stage: bookshelf pane + detail pane ---------- */
.stage {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 0;
}

.shelf-pane {
  flex: 0 0 50%;
  width: 50%;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem clamp(1rem, 3vw, 2.5rem) 1.6rem;
  overflow: hidden;
  transition: flex-basis 0.4s ease, width 0.4s ease;
}

/* ---------- Library / Shelves ---------- */
.library {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(0.3rem, 1.2vh, 0.9rem);
  overflow: hidden;
}

.library-message {
  color: var(--text-light);
  text-align: center;
}

.shelf {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.shelf-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 clamp(0.2rem, 0.8vh, 0.6rem) 0.15rem;
}

.shelf-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(0.95rem, 2.3vh, 1.3rem);
  letter-spacing: 0.2px;
  color: var(--accent);
  text-shadow: 0 2px 6px rgba(var(--ink-rgb), 0.5);
  margin: 0;
}

.shelf-count {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-muted);
}

/* Wraps the scrollable row plus its two click-zone nav buttons */
.shelf-viewport {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  display: flex;
}

.shelf-row {
  display: flex;
  align-items: stretch;
  gap: clamp(0.6rem, 1.6vw, 1.2rem);
  flex-wrap: nowrap;
  padding: 0 0.4rem 6px;
  position: relative;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.shelf-row::-webkit-scrollbar {
  display: none;
}

/* Left/right click zones that scroll only their own row */
.shelf-nav {
  appearance: none;
  border: none;
  cursor: pointer;
  position: absolute;
  top: 0;
  bottom: 6px;
  width: 40px;
  display: flex;
  align-items: center;
  color: var(--text-light);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 6;
}

.shelf-viewport.is-scrollable .shelf-nav:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
}

.shelf-nav:disabled {
  cursor: default;
}

.shelf-nav:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: none;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);
}

.shelf-nav--prev {
  left: -1rem;
  justify-content: flex-start;
  padding-left: 0.3rem;
  background: linear-gradient(to right, var(--bg-base) 30%, transparent);
}

.shelf-nav--next {
  right: -1rem;
  justify-content: flex-end;
  padding-right: 0.3rem;
  background: linear-gradient(to left, var(--bg-base) 30%, transparent);
}

.shelf-nav svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 2px 3px rgba(var(--ink-rgb), 0.6));
  transition: transform 0.2s ease;
}

.shelf-nav:hover:not(:disabled) {
  color: var(--accent);
}

.shelf-nav:hover:not(:disabled) svg {
  transform: scale(1.15);
}

/* The glass shelf each row of books/papers rests on: a thin pane of real
   glass — mostly see-through, a faint cool tint, a bright top edge catching
   the light, and a soft sheen. Deliberately understated so it reads as
   glass, not brushed steel. */
.shelf-plank {
  flex: 0 0 auto;
  height: 10px;
  margin: 0 -0.4rem 0;
  background: linear-gradient(180deg,
      rgba(var(--frost-rgb), 0.16) 0%,
      rgba(var(--frost-rgb), 0.05) 45%,
      rgba(var(--frost-rgb), 0.02) 100%);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border-top: 1px solid rgba(var(--frost-rgb), 0.5);
  border-bottom: 1px solid rgba(var(--frost-rgb), 0.08);
  border-radius: 3px;
  box-shadow:
    0 8px 16px rgba(var(--ink-rgb), 0.35),
    0 1px 0 rgba(var(--glass-rgb), 0.35) inset;
  position: relative;
  overflow: hidden;
}

.shelf-plank::before {
  /* soft cast shadow the books throw onto the glass */
  content: "";
  position: absolute;
  inset: -10px 0 auto 0;
  height: 10px;
  background: linear-gradient(to bottom, transparent, rgba(var(--ink-rgb), 0.3));
  pointer-events: none;
}

.shelf-plank::after {
  /* faint sheen across the glass surface */
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -25%;
  width: 30%;
  background: linear-gradient(115deg, transparent, rgba(var(--glass-rgb), 0.3), transparent);
  transform: skewX(-25deg);
  opacity: 0.4;
}

/* ---------- Book ---------- */
.book {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: inherit;
  position: relative;
  flex: 0 0 auto;
  width: auto;
  aspect-ratio: var(--spine-ratio, 0.66);
  transform-origin: bottom center;
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.book:focus {
  outline: none;
}

.book:hover,
.book:focus-visible {
  transform: translateY(-10px) rotate(-1deg);
}

.book:focus-visible {
  box-shadow: 0 0 0 3px var(--bg-base), 0 0 0 5px var(--accent);
  border-radius: 4px;
}

.book.is-active {
  transform: translateY(-12px) rotate(-1.5deg);
}

.book-spine {
  width: 100%;
  height: 100%;
  border-radius: 3px 7px 7px 3px;
  padding: 0.4rem 0.7rem 0.85rem 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  color: var(--text-light);
  position: relative;
  overflow: hidden;
  /* var(--spine-bg) is set per-book in bookshelf.js so every cover carries
     its own colour/gradient instead of the plain glass panel a missing
     background used to leave behind. */
  background-image:
    linear-gradient(122deg, transparent 24%, rgba(var(--glass-rgb), 0.22) 40%, transparent 56%),
    var(--spine-bg, linear-gradient(160deg, rgba(var(--glass-rgb), 0.1), rgba(var(--glass-rgb), 0.02)));
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  border: 1px solid rgba(var(--glass-rgb), 0.16);
  box-shadow:
    -3px 3px 6px rgba(var(--ink-rgb), 0.3),
    5px 6px 14px rgba(var(--ink-rgb), 0.35),
    inset 0 1px 0 rgba(var(--glass-rgb), 0.22);
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

.book:hover .book-spine,
.book.is-active .book-spine {
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow:
    -3px 3px 6px rgba(var(--ink-rgb), 0.35),
    8px 14px 22px rgba(var(--ink-rgb), 0.5),
    inset 0 1px 0 rgba(var(--glass-rgb), 0.22);
}

.book-spine::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(var(--glass-rgb), 0.16), rgba(var(--glass-rgb), 0.02));
}

/* fine ridges near the spine edge, still readable through the glass */
.book-spine::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 9px;
  width: 2px;
  background: rgba(var(--glass-rgb), 0.14);
  box-shadow: 4px 0 0 rgba(var(--glass-rgb), 0.08), 7px 0 0 rgba(var(--glass-rgb), 0.05);
}

/* Every title (book spine, newspaper headline, notepad title) shares one
   font size and style so the shelf reads as one system, not three. Each
   selector below only keeps the display/clamp mechanics it needs. */
.book-title,
.newspaper-headline,
.notepad-title {
  font-family: var(--serif-title);
  font-weight: 700;
  font-style: italic;
  font-size: clamp(0.95rem, 2.2vh, 1.3rem);
  line-height: 1.2;
  letter-spacing: 0.2px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(var(--ink-rgb), 0.4);
}

.book-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

/* Category-specific silhouettes for a more "real shelf" feel */
.shelf[data-category="novels"] .book {
  --spine-ratio: 1.0;
}

.shelf[data-category="novels"] .book-spine {
  border-left: 4px solid rgba(var(--ink-rgb), 0.35);
}

.shelf[data-category="shortstories"] .book {
  --spine-ratio: 0.78;
}

.shelf[data-category="tech"] .book {
  --spine-ratio: 0.9;
}

/* Tech shelf hangs its papers on a slim glass rod rather than a full glass shelf */
.shelf[data-category="tech"] .shelf-plank {
  height: 7px;
  border-radius: 999px;
}

/* ---------- Newspaper (tech shelf) ---------- */
.newspaper {
  --tilt: 0deg;
  width: 100%;
  height: 100%;
  /* Every category gets its own colour identity: tech's paper carries a
     cool teal tint so it reads distinctly from the warm novel spines. */
  background-image:
    linear-gradient(122deg, transparent 24%, rgba(var(--glass-rgb), 0.16) 40%, transparent 56%),
    linear-gradient(160deg, rgba(var(--sky-rgb), 0.16), rgba(var(--sky-rgb), 0.03));
  backdrop-filter: blur(6px) saturate(140%);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  border: 1px solid rgba(var(--glass-rgb), 0.16);
  color: var(--text-light);
  padding: 0.3rem 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  position: relative;
  transform: rotate(var(--tilt));
  box-shadow:
    0 10px 18px rgba(var(--ink-rgb), 0.35),
    0 3px 5px rgba(var(--ink-rgb), 0.25),
    inset 0 1px 0 rgba(var(--glass-rgb), 0.16);
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

.newspaper-headline {
  flex: 1.6 1 0;
  min-height: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-box-pack: start;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}

.newspaper-rule {
  flex: 0 0 auto;
  height: 3px;
  border-top: 2px solid rgba(var(--mist-rgb), 0.7);
  border-bottom: 1px solid rgba(var(--mist-rgb), 0.35);
}

/* faux justified body-copy columns */
.newspaper-columns {
  flex: 0.7 1 0;
  /* Needs real px, not 0 — the repeating-gradient "lines" pattern has a 9px
     period, so on short mobile cards a flex-shrunk sliver here renders as
     nothing at all instead of a couple of faint lines. */
  min-height: 18px;
  display: flex;
  gap: 6px;
}

.newspaper-columns::before,
.newspaper-columns::after {
  content: "";
  flex: 1;
  background-image: repeating-linear-gradient(to bottom,
      rgba(var(--mist-rgb), 0.32) 0 2px,
      transparent 2px 9px);
}

.newspaper-columns::before {
  border-right: 1px solid rgba(var(--mist-rgb), 0.18);
  padding-right: 6px;
}

.book:hover .newspaper,
.book.is-active .newspaper {
  border-color: rgba(var(--sky-rgb), 0.55);
  box-shadow:
    0 16px 26px rgba(var(--ink-rgb), 0.45),
    0 3px 5px rgba(var(--ink-rgb), 0.25),
    inset 0 1px 0 rgba(var(--glass-rgb), 0.22);
}

/* ---------- Notepad (short stories shelf): a scribbled-on jotter pad ---------- */
.notepad {
  --tilt: 0deg;
  width: 100%;
  height: 100%;
  background-color: var(--surface-ink);
  background-image:
    linear-gradient(160deg, rgba(var(--accent-2-rgb), 0.1), transparent 55%),
    repeating-linear-gradient(to bottom,
      transparent 0 27px,
      rgba(var(--mist-rgb), 0.28) 27px 28px);
  background-position: 0 0, 0 6px;
  border-radius: 3px 3px 9px 9px;
  border: 1px solid rgba(var(--mist-rgb), 0.18);
  padding: 0.65rem 1rem 1rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  transform: rotate(var(--tilt));
  box-shadow:
    -3px 4px 10px rgba(var(--ink-rgb), 0.4),
    4px 8px 16px rgba(var(--ink-rgb), 0.45);
  overflow: hidden;
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

/* silver margin rule, classic ruled notepad */
.notepad::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1.15rem;
  width: 1px;
  background: rgba(var(--mist-rgb), 0.4);
}

/* torn perforated edge along the top */
.notepad::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background:
    linear-gradient(135deg, transparent 45%, var(--surface-ink) 45%) 0 0 / 8px 8px repeat-x,
    linear-gradient(-135deg, transparent 45%, var(--surface-ink) 45%) 0 0 / 8px 8px repeat-x;
}

/* spiral binding rings punched through the top */
.notepad-rings {
  position: absolute;
  top: -5px;
  left: 6px;
  right: 6px;
  height: 14px;
  background-image: radial-gradient(circle, rgba(var(--mist-rgb), 0.7) 2.1px, transparent 2.4px);
  background-size: 15px 14px;
  background-repeat: repeat-x;
  background-position: 2px 0;
}

.notepad-title {
  width: 100%;
  color: var(--text-light);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  line-clamp: 6;
  overflow: hidden;
}

.book:hover .notepad,
.book.is-active .notepad {
  border-color: rgba(var(--accent-2-rgb), 0.55);
  box-shadow:
    -3px 4px 10px rgba(var(--ink-rgb), 0.45),
    6px 14px 22px rgba(var(--ink-rgb), 0.55);
}

/* ---------- Detail panel: docked half-screen pane on desktop ---------- */
.detail-panel {
  flex: 0 0 50%;
  width: 50%;
  height: 100%;
  min-width: 0;
  /* background: var(--panel-bg); */
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  /* border: 1px solid rgba(var(--glass-rgb), 0.1); */
  color: var(--text-light);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(var(--ink-rgb), 0.45);
  overflow-y: auto;
  position: relative;
  transition: flex-basis 0.4s ease, width 0.4s ease, opacity 0.3s ease;
}

/* Desktop: the panel is normally always docked (see .stage), but once the
   about intro itself has been closed there's nothing to keep it open for —
   collapse it and let the shelf take the full width, until the info icon
   (see .info-toggle below) brings it back. */
@media (min-width: 861px) {
  body.panel-closed .shelf-pane {
    flex-basis: 100%;
    width: 100%;
  }

  body.panel-closed .detail-panel {
    flex-basis: 0;
    width: 0;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    overflow: hidden;
  }

  body.panel-closed .info-toggle {
    display: flex;
  }
}

.detail-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.5rem, 4vh, 3rem) clamp(1.5rem, 3vw, 3rem);
}

/* The site intro (about text), shown by default in the docked desktop panel
   and opened via the mobile info icon. Reuses the detail-tag/title/description
   styling that book selections use. */
.detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  animation: detailFadeIn 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.detail-placeholder .detail-title {
  text-align: center;
  align-self: center;
}

.detail-email {
  color: var(--accent-2);
  text-decoration-color: rgba(var(--accent-2-rgb), 0.5);
  text-underline-offset: 2px;
}

.detail-email:hover,
.detail-email:focus-visible {
  color: var(--accent-hover);
}

/* Stray empty .detail-meta elements used to render this rule with nothing
   above it; put it on the disclaimer itself instead so it only ever shows
   up when there's real content to divide from. */
.detail-disclaimer {
  padding-top: 1.2rem;
  border-top: 1px solid rgba(var(--glass-rgb), 0.12);
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.detail-placeholder[hidden],
.detail-content[hidden] {
  display: none;
}

.detail-content {
  position: relative;
  animation: detailFadeIn 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes detailFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(var(--glass-rgb), 0.14);
  background: rgba(var(--glass-rgb), 0.08);
  color: var(--text-light);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.detail-close:hover {
  background: rgba(var(--glass-rgb), 0.16);
  transform: rotate(90deg);
}

.detail-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);
}

.detail-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.8rem;
}

.detail-title {
  font-family: var(--serif-title);
  font-weight: 700;
  font-style: italic;
  font-size: clamp(1.4rem, 3.4vh, 2.1rem);
  line-height: 1.15;
  margin: 0 0 0.9rem;
}

.detail-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1.4rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid rgba(var(--glass-rgb), 0.12);
}

.detail-description {
  font-size: clamp(0.9rem, 2vh, 1.05rem);
  line-height: 1.65;
  color: var(--text-light);
  opacity: 0.9;
  margin: 0 0 1.8rem;
}

/* A CTA, not a headline — kept light (tinted outline) at rest so it doesn't
   outweigh the title/excerpt above it, and only picks up real visual
   weight (solid fill) on hover/focus as feedback that it's active. */
.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(var(--accent-2-rgb), 0.12);
  color: var(--accent-2);
  border: 1px solid rgba(var(--accent-2-rgb), 0.4);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.detail-link:hover,
.detail-link:focus-visible {
  background: var(--accent-2);
  color: var(--accent-ink);
  border-color: var(--accent-2);
  transform: translateY(-2px);
}

.detail-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg-base), 0 0 0 5px var(--accent-2);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

/* Local-dev-only export button: unstyled/inert until js/export-docx.js
   confirms the page is running on localhost and un-hides it. */
.detail-link--secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: rgba(var(--glass-rgb), 0.28);
}

.detail-link--secondary:hover,
.detail-link--secondary:focus-visible {
  background: rgba(var(--glass-rgb), 0.14);
  color: var(--text-light);
  border-color: rgba(var(--glass-rgb), 0.4);
}

.detail-link--secondary:focus-visible {
  box-shadow: 0 0 0 3px var(--bg-base), 0 0 0 5px rgba(var(--glass-rgb), 0.4);
}

.detail-link--secondary:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.detail-link--secondary[hidden] {
  display: none;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(var(--ink-rgb), 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 40;
  display: none;
}

/* ---------- Mobile / device: full-screen shelf, popup detail card ---------- */
@media (max-width: 860px) {
  .site-header {
    padding: 0.5rem 2.6rem 0.4rem 1rem;
  }

  .site-title {
    font-size: clamp(1.1rem, 6.5vw, 1.5rem);
  }

  .info-toggle {
    display: flex;
  }

  .mail-menu {
    top: 0.5rem;
    right: 0.6rem;
  }

  .mail-toggle {
    width: 28px;
    height: 28px;
  }

  .mail-panel {
    right: -0.4rem;
    min-width: 152px;
  }

  .shelf-heading {
    font-size: 0.95rem;
  }

  .site-footer {
    position: static;
    display: block;
    text-align: center;
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
  }

  .stage {
    flex-direction: column;
  }

  .shelf-pane {
    flex: 1 1 auto;
    width: 100%;
    padding: 0.6rem 1rem;
  }

  .shelf-row {
    gap: 0.7rem;
  }

  .shelf-nav {
    width: 32px;
  }

  /* Give the headline more room on narrow cards, where 1.6vh reads too small */
  .newspaper-headline {
    font-size: clamp(0.85rem, 5vw, 2rem);
  }

  .notepad-title {
    font-size: clamp(0.85rem, 5vw, 2rem);
  }

  .book-title {
    font-size: clamp(0.85rem, 5vw, 2rem);
  }

  .detail-overlay {
    display: block;
  }

  .detail-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .detail-panel {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    top: auto;
    width: min(360px, 92vw);
    height: auto;
    max-height: 72vh;
    transform: translate(-50%, 16px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 60;
    border-radius: 20px;
  }

  .detail-panel.is-open {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }

  .detail-inner {
    min-height: auto;
    justify-content: flex-start;
    padding: 2.8rem 1.4rem 1.6rem;
  }

  .detail-close {
    top: 0.7rem;
    right: 0.7rem;
    width: 32px;
    height: 32px;
    background: var(--accent-2);
    border-color: rgba(var(--ink-rgb), 0.15);
    color: var(--accent-ink);
  }

  .detail-close:hover {
    background: var(--accent-hover);
    transform: none;
  }
}