:root {
  --ink: #1a2a32;
  --ink-soft: #3d4a50;
  --paper: #f3efe6;
  --paper-2: #fffaf3;
  --line: #d7d0c3;
  --gold: #c4a36a;
  --gold-soft: #e8d7b0;
  --rust: #b4452d;
  --rust-dark: #8e3320;
  --muted: #6a6258;
  --ok: #2d6a4f;
  --error: #9b2335;
  --header: #17242b;
  --player: #141e24;
  --shadow: 0 10px 30px rgba(20, 24, 20, 0.10);
  --radius: 18px;
  --font-serif: Palatino, "Palatino Linotype", "Iowan Old Style", "Book Antiqua", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --player-h: 7.2rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom)); }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--rust-dark); }
a:hover { color: var(--rust); }

.site-header {
  background: var(--header);
  color: #f6efe3;
  padding: 1.1rem 1.4rem 1.2rem;
  border-bottom: 4px solid var(--gold);
}
.header-inner { max-width: 1100px; margin: 0 auto; }
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin: 0 0 0.2rem;
}
.site-header h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.tagline {
  margin: 0.25rem 0 0;
  color: #d9d0c3;
  font-size: 1.05rem;
}

.listen-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.2rem calc(var(--player-h) + env(safe-area-inset-bottom) + 1.5rem);
}
.empty-state {
  text-align: centre;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  padding: 3rem 1rem;
}

.track-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
}

.track-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
@media (min-width: 720px) {
  /* Side-by-side cards so the title stays visible on iPad landscape */
  .track-card {
    flex-direction: row;
    align-items: stretch;
    min-height: 220px;
  }
  .track-card .cover-wrap {
    flex: 0 0 240px;
    width: 240px;
    max-width: 42%;
    aspect-ratio: 1 / 1;
  }
  .track-card .track-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.1rem 1.2rem;
  }
  .track-title { font-size: 1.6rem; }
}
@media (min-width: 1100px) {
  .track-grid { grid-template-columns: 1fr 1fr; }
  .track-card .cover-wrap { flex-basis: 220px; width: 220px; }
}
.track-card.is-current,
.track-card.is-featured {
  border-color: var(--gold);
  box-shadow: 0 10px 28px rgba(180, 69, 45, 0.12);
}
.cover-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #1a2a32;
}
.cover-wrap .cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.play-fab {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  width: 4.1rem;
  height: 4.1rem;
  border: 0;
  border-radius: 50%;
  background: var(--rust);
  color: #fffaf3;
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.play-fab:hover,
.play-fab:focus-visible { background: var(--rust-dark); outline: none; }
.play-fab svg { width: 1.8rem; height: 1.8rem; fill: currentColor; display: none; }
.play-fab .icon-play { display: block; margin-left: 3px; }
.play-fab.is-playing .icon-play { display: none; }
.play-fab.is-playing .icon-pause { display: block; margin-left: 0; }

.track-body { padding: 0.9rem 1rem 1.05rem; }
.track-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
  line-height: 1.2;
}
.track-desc {
  margin: 0 0 0.6rem;
  color: var(--ink-soft);
  font-size: 1rem;
}
.track-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
}
.text-btn {
  background: none;
  border: 0;
  padding: 0.45rem 0;
  color: var(--rust-dark);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.text-btn[aria-expanded="true"] { color: var(--ink); }
.play-count { color: var(--muted); font-size: 0.92rem; }
.lyrics {
  margin-top: 0.6rem;
  background: #f6f1e8;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
}
.lyrics pre {
  font-family: var(--font-serif);
  white-space: pre-wrap;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.55;
}

/* Sticky player */
.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--player);
  color: #f4eee4;
  border-top: 3px solid var(--gold);
  z-index: 40;
  padding: 0.65rem 0.9rem calc(0.65rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.18);
}
.player-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "cover meta controls"
    "seek seek seek";
  gap: 0.45rem 0.85rem;
  align-items: center;
}
.player-cover {
  grid-area: cover;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 8px;
  object-fit: cover;
  background: #24313a;
}
.player-meta { grid-area: meta; min-width: 0; }
.player-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-artist {
  margin: 0.05rem 0 0;
  color: #c9c0b3;
  font-size: 0.92rem;
}
.player-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.ctrl {
  width: 3.1rem;
  height: 3.1rem;
  border: 0;
  background: transparent;
  color: #f4eee4;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.ctrl svg { width: 1.55rem; height: 1.55rem; fill: currentColor; }
.ctrl-main {
  width: 3.7rem;
  height: 3.7rem;
  background: var(--rust);
}
.ctrl-main:hover, .ctrl-main:focus-visible { background: var(--rust-dark); outline: none; }
.ctrl-main .icon-play, .ctrl-main .icon-pause { display: none; }
.ctrl-main .icon-play { display: block; margin-left: 2px; }
.player.is-playing .ctrl-main .icon-play { display: none; }
.player.is-playing .ctrl-main .icon-pause { display: block; margin-left: 0; }
.player-seek {
  grid-area: seek;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
  color: #c9c0b3;
}
.player-seek input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1.6rem;
  background: transparent;
  margin: 0;
}
.player-seek input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: #3a4a52;
  border-radius: 99px;
}
.player-seek input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 0;
  margin-top: -8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.player-seek input[type="range"]::-moz-range-track {
  height: 6px;
  background: #3a4a52;
  border-radius: 99px;
  border: 0;
}
.player-seek input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  border: 0;
}

@media (min-width: 800px) {
  .player-inner {
    grid-template-columns: auto minmax(10rem, 1.1fr) auto minmax(12rem, 1.4fr);
    grid-template-areas: "cover meta controls seek";
  }
  .player-cover { width: 3.8rem; height: 3.8rem; }
}

/* Admin / forms */
.page-admin { background: #efe9dc; }
.centre-card, .admin-wrap { max-width: 820px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }
.centre-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 8vh;
  padding: 1.6rem 1.4rem 2rem;
}
.centre-card h1, .admin-header h1 {
  font-family: var(--font-serif);
  margin: 0 0 0.4rem;
  font-size: 2rem;
}
.lede { color: var(--ink-soft); margin: 0 0 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.45rem; }
.stack label { font-weight: 600; margin-top: 0.5rem; }
.optional { font-weight: 400; color: var(--muted); }
.big-input, textarea, select {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid #cfc7b8;
  border-radius: 12px;
  background: #fff;
  font-size: 1.1rem;
}
textarea { resize: vertical; min-height: 8rem; line-height: 1.45; }
.big-input:focus, textarea:focus {
  outline: 3px solid var(--gold-soft);
  border-color: var(--gold);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.1rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  font-size: 1.05rem;
}
.btn-primary {
  background: var(--rust);
  color: #fffaf3;
  border-color: var(--rust);
}
.btn-primary:hover { background: var(--rust-dark); color: #fffaf3; }
.btn-file {
  background: #fff;
  color: var(--ink);
  border-color: #cfc7b8;
  min-width: 10rem;
}
.btn-small {
  min-height: 2.6rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.95rem;
  background: #fff;
  border: 1px solid #cfc7b8;
  color: var(--ink);
  border-radius: 999px;
}
.btn-small:disabled { opacity: 0.4; cursor: default; }
.btn-danger { color: var(--error); border-color: #e0b4ba; }
.btn + .btn { margin-left: 0; }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}
.admin-links { display: flex; gap: 1rem; margin: 0; }
.admin-links a { font-weight: 600; color: var(--ink); }
.admin-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.15rem 1.4rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}
.admin-card h2 {
  font-family: var(--font-serif);
  margin: 0 0 0.8rem;
  font-size: 1.45rem;
}

/* File picker: hide the native control visually, keep it reachable via its label.
   Avoid display:none — that can stop iPad Safari opening the picker. */
.file-row {
  position: relative;
  margin: 0.6rem 0 0.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.8rem;
}
.file-label { font-weight: 600; flex: 1 1 100%; }
.file-row input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.file-name { color: var(--muted); font-size: 0.98rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.6rem;
  font-weight: 500;
}
.check-row input { width: 1.2rem; height: 1.2rem; }

.admin-tracks { list-style: none; margin: 0; padding: 0; }
.admin-track {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.admin-track:first-child { border-top: 0; }
.admin-track img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.admin-track-body { min-width: 0; }
.admin-track-body strong { font-size: 1.12rem; }
.admin-track .muted { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.95rem; }
.admin-track-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.admin-track.is-hidden { opacity: 0.72; }
.pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #efe0c8;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.inline { display: inline; }
.edit-cover img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 1rem;
}

.flashes { max-width: 820px; margin: 0.8rem auto 0; padding: 0 1rem; }
.flash { padding: 0.7rem 0.9rem; border-radius: 12px; margin: 0 0 0.6rem; }
.flash-error, .flash-danger { background: #fde8ea; color: #6d1522; }
.flash-ok, .flash-success { background: #e5f4ea; color: #1d4d35; }

.share-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-h) + 0.8rem);
  transform: translateX(-50%);
  background: var(--ink);
  color: #fffaf3;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  z-index: 50;
  font-weight: 600;
}
