/* Colours from MRLAstro (web/static/styles.css). */
:root {
  --primary: #512DA8;
  --primary-dark: #311B92;
  --primary-light: #EDE7F6;
  --label: #777777;
  --value: #1A1A1A;
  --primary-hover: #4527A0;
  --divider: #EEEEEE;
}
* { box-sizing: border-box; }
/* Phone behaviours, as in MRLAstro: branded tap feedback, no rubber-band over-scroll,
   room for the notch and home indicator (env() is 0 where there is none). */
html { -webkit-tap-highlight-color: rgba(81, 45, 168, 0.15); }
header, nav, button { -webkit-user-select: none; user-select: none; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--value);
  background: #fff;
  overscroll-behavior-y: contain;
  padding-bottom: env(safe-area-inset-bottom);
}
/* MRLAstro's purple bar with its logo, centred. */
header { background: var(--primary); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 16px 0; text-align: center; }
.brand { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.brand img { margin-right: 8px; }
.masters { font-size: .9rem; margin: -4px 0 8px; opacity: .9; }
nav { display: flex; justify-content: center; gap: 4px; }
.tab {
  background: none; border: 0; color: #fff; opacity: .75; font: inherit; font-weight: 600;
  padding: 10px 22px; cursor: pointer; border-bottom: 3px solid transparent;
}
.tab.active { opacity: 1; border-bottom-color: #fff; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.card { background: #fff; border: 1px solid var(--divider); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
/* MRLAstro's .section-header chip. */
.label {
  display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--primary-dark); background: var(--primary-light); padding: 4px 8px; border-radius: 4px;
}
.title { font-size: 1.4rem; font-weight: 700; color: var(--primary-dark); margin: 10px 0 4px; }
.left { color: var(--label); margin-bottom: 16px; }
.next { color: var(--value); font-weight: 600; margin-top: 8px; }
.onair { text-align: center; }

button.big {
  background: var(--primary); color: #fff; border: 0; border-radius: 32px; font: inherit; font-size: 1.15rem;
  font-weight: 600; padding: 14px 36px; margin: 8px auto 24px; cursor: pointer; display: block;
}
button.big:hover { background: var(--primary-hover); }
button.big.playing { background: #fff; color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }

.player .title { font-size: 1.1rem; }
/* Keep the player in view while scrolling the track list on a phone. */
.player { position: sticky; top: 0; z-index: 1; }
/* Our own player: a large play button (easy to tap on a phone) and a seek bar. */
.transport { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.playbtn {
  flex: none; width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 1.6rem; line-height: 1;
}
.playbtn:disabled { opacity: .4; cursor: default; }
.seek { flex: 1; min-width: 0; }
.seek input { width: 100%; height: 32px; margin: 0; accent-color: var(--primary); }
.times { display: flex; justify-content: space-between; font-size: .8rem; color: var(--label); }

/* Series: one row each, tap to open. */
#lib-list details { border: 1px solid var(--divider); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
#lib-list summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; list-style: none; cursor: pointer;
  padding: 14px 16px; font-weight: 700; color: var(--primary-dark); background: #fff;
}
#lib-list summary::-webkit-details-marker { display: none; }
#lib-list summary::before { content: '▸'; color: var(--primary); transition: transform .15s; }
#lib-list details[open] summary::before { transform: rotate(90deg); }
#lib-list summary .name { flex: 1; }
#lib-list summary .meta { color: var(--label); font-weight: 400; font-size: .85rem; white-space: nowrap; }
#lib-list details[open] summary { border-bottom: 1px solid var(--divider); }

.track {
  position: relative; display: flex; justify-content: space-between; width: 100%; text-align: left; font: inherit;
  background: #fff; border: 0; border-bottom: 1px solid var(--divider); padding: 12px 16px; cursor: pointer;
}
.track:last-child { border-bottom: 0; }
.track.done .name::after { content: ' ✓'; color: var(--primary); font-weight: 700; }
/* How much of the lecture you have heard. */
.track .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.track .bar i { display: block; height: 100%; width: 0; background: var(--primary); opacity: .6; }
.track:hover { background: var(--primary-light); }
.track.current { background: var(--primary-light); font-weight: 600; }
.track .meta { color: var(--label); font-size: .9rem; white-space: nowrap; margin-left: 12px; }
#lib-now:empty { display: none; }

/* The note at the bottom of the page. */
footer { max-width: 640px; margin: 8px auto 0; padding: 16px 16px 32px; text-align: center; font-size: .8rem; line-height: 1.5; color: var(--label); }
footer a { color: var(--primary); }

/* Install banner, at the bottom of the screen. */
#install {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 2;
  max-width: 616px; margin: 0 auto; padding: 14px 16px; border-radius: 12px;
  background: var(--primary-light); color: var(--primary-dark); box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
}
#install[hidden] { display: none; }
#install div { margin: 4px 0 10px; color: var(--value); }
#install button {
  font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; margin-right: 8px;
  border: 1px solid var(--primary); background: #fff; color: var(--primary);
}
#install #install-yes { background: var(--primary); color: #fff; }
#install #install-yes[hidden] { display: none; }

/* Phones: a smaller, tighter Library list (rows stay at least 40px tall to tap easily). */
@media (max-width: 600px) {
  #lib-list details { border-radius: 10px; margin-bottom: 6px; }
  #lib-list summary { padding: 10px 12px; font-size: .95rem; gap: 8px; min-height: 40px; }
  #lib-list summary .meta { font-size: .75rem; }
  .track { padding: 9px 12px; font-size: .875rem; min-height: 40px; align-items: center; }
  .track .meta { font-size: .75rem; }
}
