:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --text: #e8eaf0;
  --text-soft: #c6ccd8;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --border: #2a2f3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* site background image, dimmed so the dark theme stays readable */
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(15, 17, 21, 0.88), rgba(15, 17, 21, 0.88)),
    url("data/images/bkgd.jpg");
  background-size: auto, cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.55;
}

/* Links: the UA default blue/purple is unreadable on the dark background,
   so use the accent palette everywhere (post descriptions inject raw HTML
   links via innerHTML, hence the global selector). */
a {
  color: var(--accent);
  text-decoration-color: rgba(110, 168, 254, 0.45);
  text-underline-offset: 2px;
}
a:visited { color: #b39ddb; text-decoration-color: rgba(179, 157, 219, 0.45); }
a:hover { color: #9ec1ff; text-decoration-color: currentColor; }
a:active { color: #d3e2fd; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Header band: the banner image behind the logo. */
.site-header {
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
  /* background-image:
    linear-gradient(rgba(15, 17, 21, 0.35), rgba(15, 17, 21, 0.7)),
    url("images/header.jpg"); */
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
}
.site-header h1 { margin: 0; }
.site-logo {
  height: 64px;
  width: auto;
  display: inline-block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}
.tagline { margin: 0.4rem 0 0; color: var(--text-soft); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }

main {
  max-width: 760px;
  margin: 0 auto;
  /* extra bottom padding so the fixed player bar never hides the last post */
  padding: 1.5rem 1.5rem calc(1.5rem + 3.5rem);
}

.status {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0;
}
.status.error { color: #ff8a8a; }

/* Vertical feed: posts stacked one above another, loaded on scroll. */
.feed {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.post {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.1rem;
  transition: border-color 0.15s ease;
  /* a post reached via its #anchor scrolls clear of the fixed player bar */
  scroll-margin-top: 1rem;
  scroll-margin-bottom: 4.5rem;
}
.post:hover { border-color: var(--accent); }
/* the post a shared #anchor link points to stays highlighted */
.post:target { border-color: var(--accent); box-shadow: 0 0 12px rgba(110, 168, 254, 0.25); }
/* contain the floated thumbnail and player */
.post::after { content: ""; display: block; clear: both; }

/* Small thumbnail, top-left of the post; text flows around it.
   max-width/max-height (not a fixed box + object-fit:cover) so the whole
   image is always visible whatever its aspect ratio, and no background so
   transparent PNGs blend into the post panel behind them. */
.post-thumb {
  float: left;
  max-width: 96px;
  max-height: 96px;
  border-radius: 8px;
  margin: 0.2rem 1rem 0.4rem 0;
}

/* Song list, floating on the right side of the post (only when it has songs). */
.post-player {
  float: right;
  width: 230px;
  margin: 0.2rem 0 0.6rem 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--panel-2);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* One row per song; the "bullet" is a play button that drives the global
   player fixed at the bottom of the screen. */
.song-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.song-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  color: var(--text-soft);
}
.song-item:hover { background: var(--panel); }
.song-item.current {
  background: var(--panel);
  outline: 1px solid var(--accent);
  color: var(--text);
}
.song-play {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  font-size: 0.6rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.song-play:hover { border-color: var(--accent); }
.song-item.current .song-play {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
}
.song-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The unique player: a condensed bar fixed at the bottom of the screen,
   overlaying the feed. One row: play/pause, title, seek, timing, volume. */
.global-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: rgba(30, 34, 43, 0.97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.45);
}
/* hidden until the first song plays (the class's display:flex would
   otherwise override the UA [hidden] rule) */
.global-player[hidden] { display: none; }
.global-player audio { display: none; }
.gp-toggle {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gp-toggle:hover:not(:disabled) { border-color: var(--accent); }
.gp-toggle:disabled { opacity: 0.45; cursor: default; }
.global-player.playing .gp-toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
}
.gp-title {
  flex: 0 1 auto;
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.gp-seek {
  flex: 1 1 auto;
  min-width: 60px;
  height: 4px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.gp-time {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gp-volume {
  flex: 0 0 auto;
  width: 84px;
  height: 4px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Title, then date, then description (HTML) — wraps around the floats. */
.post-body { min-width: 0; }
.post-title { margin: 0; font-size: 1.2rem; }
.post-date {
  display: block;
  margin: 0.15rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
}
/* small copiable #anchor link shown next to the date */
.post-anchor {
  margin-left: 0.45rem;
  font-size: 0.72rem;
  text-decoration: none;
  opacity: 0.55;
}
.post-anchor:hover { opacity: 1; text-decoration: none; }
.post-desc { margin: 0; color: var(--text-soft); font-size: 0.95rem; }
.post-desc img, .post-desc video { max-width: 100%; height: auto; }
.post-desc code {
  background: var(--panel-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.feed-sentinel {
  text-align: center;
  color: var(--muted);
  min-height: 1.2em;
  margin: 1.25rem 0 0;
}

.feed-info {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.25rem 0 2rem;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}
.site-footer code { color: var(--accent); }

/* Small screens: stack the post vertically — thumbnail, text, then the
   song list full-width at the bottom (avoids overlap with the floated
   thumb); the global player stays one condensed row. */
@media (max-width: 640px) {
  /* fixed backgrounds render zoomed on iOS — let it scroll instead */
  body { background-attachment: scroll; }
  .site-logo { height: 48px; }
  .post { display: flex; flex-direction: column; }
  .post::after { content: none; }
  .post-thumb { order: 0; float: none; align-self: flex-start; max-width: 72px; max-height: 72px; margin: 0 0 0.5rem; }
  .post-body { order: 1; }
  .post-player { order: 2; float: none; width: auto; margin: 0.75rem 0 0; }
  .global-player { gap: 0.4rem; padding: 0.4rem 0.6rem; }
  .gp-toggle { width: 1.7rem; height: 1.7rem; font-size: 0.65rem; }
  .gp-title { max-width: 32%; font-size: 0.8rem; }
  .gp-seek { min-width: 36px; }
  .gp-time { font-size: 0.68rem; }
  .gp-volume { width: 52px; }
}
