:root {
  --paper: #f5f9ee;
  --paper-deep: #e9efde;
  --ink: #1a1f15;
  --muted: #5f6b58;
  --accent: #2f6b3f;
  --accent-soft: #dde9d0;
  --rule: #c9d5bc;
  --measure: 64ch;
  --serif: "Fraunces", "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 17px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: "onum" 1, "kern" 1;
  line-height: 1.65;
  background-image:
    radial-gradient(rgba(0,0,0,0.013) 1px, transparent 1px),
    radial-gradient(rgba(47,107,63,0.025) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 1px;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p, li { max-width: var(--measure); }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

main {
  padding: 1.5rem clamp(1rem, 5vw, 3rem) 4rem;
  max-width: 80ch;
  margin: 0 auto;
}

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.4rem clamp(1rem, 5vw, 3rem);
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 80ch;
  margin: 0 auto;
}
.site-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.3rem;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.site-title .dot { color: var(--accent); }
.site-header nav { display: flex; gap: 1.4rem; font-size: 0.95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem clamp(1rem, 5vw, 3rem);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  max-width: 80ch;
  margin: 0 auto;
}
.site-footer a { color: var(--muted); }

/* Section rule (hand-set look) */
.section-rule {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 2.4rem 0 1.4rem;
}
.section-rule::before, .section-rule::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}
.section-rule span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 0 0.2rem;
}

/* Intro */
.intro {
  padding: 1.5rem 0 1rem;
  position: relative;
}
.intro h1 {
  font-size: clamp(2.6rem, 8vw, 4.8rem);
  margin: 0 0 1rem -0.04em;
  font-style: normal;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.intro h1 .ital { font-weight: 600; color: var(--accent); }
.intro h1 .dot { color: var(--accent); }
.intro .lead {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  max-width: 56ch;
}

/* Song grid */
.song-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2.2rem 1.6rem;
}
.song-card a {
  display: block;
  text-decoration: none;
  color: var(--ink);
}
.song-card-image {
  position: relative;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  overflow: hidden;
}
.song-card-image::after {
  /* faint paper noise */
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.song-card-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  filter: saturate(0.9) contrast(0.96);
}
.song-card h3 {
  margin: 0.7rem 0 0.15rem;
  font-weight: 500;
  font-size: 1.15rem;
}
.song-card .card-sub {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 0.3rem;
  max-width: none;
}
.song-card .card-tags {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: lowercase;
  max-width: none;
}
.song-card a:hover h3 { color: var(--accent); }
.song-card a:hover .song-card-image { border-color: var(--ink); }

/* "new" badge */
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background: var(--accent);
  color: var(--paper);
  padding: 2px 7px;
  vertical-align: 0.18em;
  margin-left: 0.3em;
  border-radius: 1px;
}

/* Coming-soon section */
.coming-soon p { color: var(--muted); }

/* ---------- Song page ---------- */
.song-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin: 1rem 0 0.5rem;
  align-items: start;
}
@media (min-width: 640px) {
  .song-hero { grid-template-columns: 240px 1fr; gap: 2.2rem; }
}
.song-hero-image {
  position: relative;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}
.song-hero-image::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.song-hero-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  filter: saturate(0.9);
}
.song-hero-text h1 {
  margin-top: -0.2rem;
}
.song-hero-text .lead {
  color: var(--muted);
  font-size: 1.08rem;
  margin: 0.2rem 0 1rem;
}
.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  font-size: 0.95rem;
  margin: 0;
}

/* Tracks */
.listen { margin-top: 1.5rem; }
.track {
  margin: 1.2rem 0;
  padding: 0.8rem 1rem 0.8rem 1.1rem;
  border-left: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.track:target {
  border-left-color: var(--accent);
  background: linear-gradient(to right, var(--accent-soft), transparent 70%);
}
.track h3 {
  margin: 0 0 0.5rem;
  font-style: normal;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.track h3 a {
  color: var(--rule);
  text-decoration: none;
  margin-right: 0.3rem;
  font-family: var(--serif);
}
.track:hover h3 a, .track:target h3 a { color: var(--accent); }
.track audio {
  width: 100%;
  max-width: 480px;
  /* Subtle styling on the native player */
  border-radius: 0;
}
.track-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.track-cover .track-note { font-style: italic; }

/* Lyrics */
.lyrics { margin-top: 1.5rem; }
.lyrics-body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
  margin: 1rem 0;
  padding: 0;
}
.lyrics-body strong {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.other-langs {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 1.2rem;
}

/* Standalone lyrics page */
.lyrics-page .back { font-size: 0.95rem; margin-bottom: 1rem; }
.lyrics-page .lang-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  margin: 0 0 1.2rem;
}

/* Intro link */
.intro-link {
  margin-top: 1rem;
  font-size: 0.95rem;
}
.intro-link a { font-style: normal; }

/* Homepage section lists for stories / poems / etc. */
.prose-section, .more-section { margin-top: 2.5rem; }
.prose-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.4rem;
}
.prose-list li {
  max-width: var(--measure);
  padding-left: 0.9rem;
  border-left: 2px solid var(--accent-soft);
  transition: border-color 0.15s;
}
.prose-list li:hover { border-left-color: var(--accent); }
.prose-list h3 {
  margin: 0 0 0.2rem;
  font-size: 1.15rem;
  font-weight: 500;
}
.prose-list h3 a { color: var(--ink); text-decoration: none; }
.prose-list h3 a:hover { color: var(--accent); text-decoration: underline; }
.prose-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Prose pages (stories, poems, static) */
.prose .back, .song > .back {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--muted);
}
.prose .back a, .song > .back a { color: var(--muted); }
.prose h1 { margin-top: 0.4rem; }
.prose .lead {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 1.15rem;
  margin: 0.2rem 0 1.5rem;
}
.prose-notice {
  margin: 1.2rem 0 1.8rem;
  padding: 0.9rem 1.1rem;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: 0.92rem;
  color: var(--ink);
}
.prose-notice a { color: var(--accent); }
.prose-body {
  font-size: 1.05rem;
  line-height: 1.75;
}
.prose-body p, .prose-body li {
  max-width: var(--measure);
}
.prose-body p { margin: 0 0 1.1em; }
.prose-body h2, .prose-body h3, .prose-body h4 {
  margin-top: 2rem;
  font-weight: 500;
}
.prose-body h2 { font-size: 1.55rem; }
.prose-body h3 { font-size: 1.25rem; }
.prose-body h4 { font-size: 1.05rem; font-family: var(--sans); letter-spacing: 0.01em; }
.prose-body blockquote {
  margin: 1.2rem 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--accent-soft);
  color: var(--muted);
  font-style: italic;
}
/* Default <pre> in prose is monospace + non-wrapping — 1990s-era pages
   often contain column-aligned ASCII tables (mcdougal, ardiscus). */
.prose-body pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  background: var(--paper-deep);
  border-left: 2px solid var(--accent-soft);
}

/* Poems use <pre> for line preservation but want soft sans typography. */
.prose.poem .prose-body pre {
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-x: visible;
  background: transparent;
  border-left: none;
  padding: 0;
}
.prose-body ul, .prose-body ol { padding-left: 1.4rem; }
.prose-body li { margin-bottom: 0.4em; }
.prose-body tt { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.95em; }
.prose-credit {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}
.prose-credit p { max-width: none; }

/* Author portrait on the welcome page */
.prose-body .portrait {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 2.5rem 0 1rem;
  padding: 0;
}
.prose-body .portrait img {
  display: block;
  width: 130px;
  height: 130px;
  object-fit: cover;
  border: 1px solid var(--accent);
  flex-shrink: 0;
  background: var(--accent-soft);
}
.prose-body .portrait figcaption {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink);
  line-height: 1.5;
  max-width: none;
}

/* Jukebox hint on homepage */
.jukebox-hint {
  margin: -0.6rem 0 1.2rem;
  font-size: 0.95rem;
}

/* Go-to-top link at end of every page */
.to-top {
  margin: 3rem 0 0;
  text-align: right;
  font-size: 0.9rem;
}
.to-top a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 1px;
}
.to-top a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* All Songs (jukebox) page */
.jukebox h1 { margin-top: 0.4rem; }
.jukebox > .lead {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 1.15rem;
  margin: 0.2rem 0 2rem;
  max-width: var(--measure);
}
.jukebox-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.jukebox-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
}
.jukebox-row:first-child {
  border-top: none;
  padding-top: 0;
}
@media (min-width: 640px) {
  .jukebox-row {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 2.2rem;
    align-items: start;
  }
}
.jukebox-poster {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.jukebox-poster-image {
  display: block;
  position: relative;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}
.jukebox-poster-image::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.jukebox-poster-image img {
  display: block;
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  filter: saturate(0.9);
}
.jukebox-poster h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}
.jukebox-poster h3 a {
  color: var(--ink);
  text-decoration: none;
}
.jukebox-poster h3 a:hover { color: var(--accent); }

/* Jukebox controls bar (Play All Covers) */
.jukebox-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.7rem 0;
  margin: 0 0 1.5rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.play-all-btn {
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: var(--paper);
  border: 1px solid var(--accent);
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  border-radius: 1px;
}
.play-all-btn:hover { filter: brightness(1.1); }
.play-all-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.play-all-btn.playing {
  background: var(--paper-deep);
  color: var(--accent);
}
.play-all-status {
  color: var(--muted);
  font-size: 0.92rem;
  font-style: italic;
  font-family: var(--serif);
}

/* Highlight the row currently playing in playlist mode */
.jukebox-track.playing {
  border-left-color: var(--accent);
  border-left-width: 3px;
  padding-left: calc(0.8rem - 1px);
  background: linear-gradient(to right, var(--accent-soft), transparent 70%);
  transition: background 0.3s, border-left-color 0.2s;
}

.jukebox-tracks {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.jukebox-subtitle {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
  max-width: none;
}
.jukebox-track {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--accent-soft);
}
.jukebox-track-cover { border-left-color: var(--accent); }
.jukebox-track-label {
  margin: 0;
  font-size: 0.92rem;
  max-width: none;
}
.jukebox-track-label strong {
  font-family: var(--sans);
  font-weight: 500;
  font-style: normal;
  color: var(--ink);
}
.jukebox-track audio {
  width: 100%;
  max-width: 480px;
}

/* PDF preview modal */
dialog#pdf-viewer {
  width: min(960px, 94vw);
  height: min(90vh, 1200px);
  max-width: 94vw;
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--accent);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 48px rgba(26,31,21,0.25);
  overflow: hidden;
}
dialog#pdf-viewer::backdrop {
  background: rgba(26,31,21,0.55);
  backdrop-filter: blur(2px);
}
.pdf-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-deep);
  flex-wrap: wrap;
}
.pdf-bar h2 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  flex: 0 0 auto;
}
.pdf-actions a { text-decoration: none; }
.pdf-actions a:hover { text-decoration: underline; }
#pdf-close {
  background: none;
  border: 1px solid var(--rule);
  font: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  width: 1.8rem; height: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
#pdf-close:hover { border-color: var(--accent); color: var(--accent); }
#pdf-frame {
  display: block;
  width: 100%;
  height: calc(100% - 50px);
  border: 0;
  background: #fff;
}

/* Song credit footer */
.song-credit {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}
.song-credit p { max-width: none; }
