:root {
  /* Blue */
  --bg-0:      #060c1e;
  --bg-1:      #0a1430;
  --navy:      #0e1c44;
  --glass:     rgba(20, 38, 84, 0.55);
  --glass-2:   rgba(28, 50, 104, 0.65);
  --hairline:  rgba(150, 180, 240, 0.14);
  --hairline-2:rgba(150, 180, 240, 0.22);
  --blue-light:#b9d0ff;
  --muted:     #8ea4cf;
  --text:      #eef3ff;

  /* Gold */
  --gold:      #e9c45e;
  --gold-hi:   #f8e08a;
  --gold-lo:   #c79a35;
  --gold-glow: rgba(233, 196, 94, 0.45);

  --r-lg: 22px;
  --r-md: 16px;
  --player-h: 104px;

  /* Shared layout width so header, books, and player all line up */
  --content-max: 680px;
  --content-pad: 16px;

  /* Classic serif like the Eckankar headings. EB Garamond is loaded from Google
     Fonts; if that's ever blocked it falls back to a system serif and the site
     still works. */
  --font-display: "EB Garamond", Garamond, "Adobe Garamond Pro", "Hoefler Text", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-width: thin; scrollbar-color: rgba(233,196,94,0.55) transparent; }

/* Themed scrollbar (replaces the default browser one) */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  border-radius: 8px; border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); background-clip: padding-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg-0);
  padding-bottom: calc(var(--player-h) + 48px + env(safe-area-inset-bottom, 0px));
  position: relative;
  overflow-x: hidden;
}

/* Ambient animated glow background */
.aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 50% -8%, rgba(233,196,94,0.10) 0%, rgba(233,196,94,0) 60%),
    radial-gradient(50% 40% at 12% 8%, rgba(70,110,220,0.30) 0%, rgba(70,110,220,0) 60%),
    radial-gradient(55% 45% at 90% 18%, rgba(120,90,230,0.22) 0%, rgba(120,90,230,0) 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 55%);
}

/* ---------- Header ---------- */
.site-header { max-width: var(--content-max); margin: 0 auto; padding: 26px var(--content-pad) 0; }
/* Header lives in the same glass frame as the book cards, aligned to the same edges */
.brand {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px;
  background: var(--glass);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}

.logo-tile {
  position: relative;
  width: 76px; height: 76px;
  display: grid; place-items: center;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(185,208,255,0.18), rgba(185,208,255,0.04) 70%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 0 0 1px var(--hairline),
    0 0 34px 2px rgba(185,208,255,0.16);
}
.logo { max-width: 60px; max-height: 60px; width: auto; height: auto; object-fit: contain;
        filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); }
.logo-fallback {
  font-weight: 800; font-size: 22px; letter-spacing: 1px;
  background: linear-gradient(160deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 4px rgba(233,196,94,0.35));
}

.site-title {
  margin: 0; font-family: var(--font-display); font-size: 29px; font-weight: 600;
  text-transform: none; letter-spacing: 0.3px; line-height: 1.05; font-style: normal;
  text-align: right;
}
.site-title { background: linear-gradient(180deg, #ffffff 0%, var(--gold-hi) 60%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Books ---------- */
.books { max-width: var(--content-max); margin: 0 auto; padding: 16px var(--content-pad) 30px; display: flex; flex-direction: column; gap: 16px; }
#books { display: flex; flex-direction: column; gap: 16px; }
.status { color: var(--muted); text-align: center; padding: 46px 10px; line-height: 1.6; }
.status.error { color: #ffb4b4; }

details.book {
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  overflow: hidden;
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
details.book:hover { transform: translateY(-1px); border-color: var(--hairline-2); }
details.book[open] {
  border-color: rgba(233,196,94,0.45);
  box-shadow: 0 16px 40px rgba(0,0,0,0.36), 0 0 0 1px rgba(233,196,94,0.18);
}

summary.book-head {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
}
summary.book-head::-webkit-details-marker { display: none; }

.book-cover {
  flex: 0 0 auto; width: 66px; height: 66px; border-radius: 15px; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(248,224,138,0.95), rgba(199,154,53,0.95));
  box-shadow: 0 6px 16px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.5);
  color: #2a1d02;
}
.book-cover svg { opacity: .92; width: 30px; height: 30px; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }

.book-title-wrap { flex: 1 1 auto; min-width: 0; }
.book-name { display: block; font-size: 17px; font-weight: 640; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.2px; }
.book-meta { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); letter-spacing: .2px; }

.chev { flex: 0 0 auto; color: var(--gold); transition: transform .28s cubic-bezier(.4,0,.2,1); display: grid; }
details.book[open] .chev { transform: rotate(180deg); }

.chapter-list { padding: 4px 8px 10px; }
.chapter {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 12px 12px; border: 0; border-radius: 12px;
  background: none; color: var(--text); font: inherit; font-size: 14.5px;
  transition: background .15s ease;
}
.chapter:hover { background: rgba(255,255,255,0.05); }
.chapter.active { background: rgba(233,196,94,0.12); }
.chapter.active .chapter-title { color: var(--gold-hi); }

.chapter .num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,0.06); color: var(--blue-light);
  border: 1px solid var(--hairline);
}
.chapter.active .num {
  background: linear-gradient(150deg, var(--gold-hi), var(--gold-lo));
  color: #2a1d02; border-color: transparent;
}
.chapter .ch-thumb {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px; overflow: hidden;
  background: rgba(255,255,255,0.06); border: 1px solid var(--hairline);
}
.chapter .ch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chapter.active .ch-thumb { border-color: var(--gold); }
.chapter .chapter-title { flex: 1 1 auto; min-width: 0; line-height: 1.4; }
.chapter .dur { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Favorite heart button on each chapter */
.chapter .favbtn {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; border: 0; background: transparent;
  color: var(--muted); transition: color .15s ease, background .15s ease, transform .08s ease;
}
.chapter .favbtn:hover { background: rgba(255,255,255,0.07); color: var(--gold-hi); }
.chapter .favbtn:active { transform: scale(.85); }
.chapter .favbtn.on { color: var(--gold); }

/* Listening history: per-chapter progress bar + finished check */
.chapter { position: relative; overflow: hidden; }
.ch-progline { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; pointer-events: none; }
.ch-progline i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-hi), var(--gold));
  border-radius: 0 2px 2px 0; transition: width .25s linear;
}
.ch-check { flex: 0 0 auto; display: none; color: var(--gold); }
.chapter.done .ch-check { display: inline-grid; place-items: center; }
.chapter.done .chapter-title { color: var(--muted); }

/* Favorites card */
details.book.favorites { border-color: rgba(233,196,94,0.40); }
details.book.favorites[open] { box-shadow: 0 16px 40px rgba(0,0,0,0.36), 0 0 0 1px rgba(233,196,94,0.22); }
.playall {
  flex: 0 0 auto; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 650;
  padding: 8px 13px; border-radius: 10px; border: 0; margin-right: 4px;
  background: linear-gradient(150deg, var(--gold-hi), var(--gold-lo)); color: #2a1d02;
  box-shadow: 0 4px 12px var(--gold-glow); transition: filter .15s ease, transform .06s ease;
}
.playall:hover { filter: brightness(1.05); }
.playall:active { transform: scale(.95); }
.playall .pa-icon { display: none; }
@media (max-width: 420px) {
  .playall .pa-text { display: none; }
  .playall .pa-icon { display: inline; }
  .playall { padding: 9px 11px; margin-right: 2px; }
  summary.book-head { padding: 14px 14px; gap: 12px; }
  .book-cover { width: 56px; height: 56px; border-radius: 13px; }
  .book-name { font-size: 15.5px; }
  .book-meta { white-space: nowrap; }
}

/* ---------- Floating player ---------- */
.player {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  /* match the book cards: same width and edges as the content above */
  width: min(calc(var(--content-max) - var(--content-pad) * 2), calc(100% - var(--content-pad) * 2));
  border-radius: var(--r-lg);
  padding: 18px 22px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(28,50,104,0.80), rgba(12,24,58,0.88));
  border: 1px solid rgba(233,196,94,0.30);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.08);
}
.player[hidden] { display: none; }

/* 1) Play button on top */
.playbtn {
  width: 66px; height: 66px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; border: 0;
  background: linear-gradient(150deg, var(--gold-hi), var(--gold-lo));
  color: #261a01;
  box-shadow: 0 10px 26px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.55);
  transition: filter .15s ease, transform .06s ease;
}
.playbtn:hover { filter: brightness(1.06); }
.playbtn:active { transform: scale(.94); }
.playbtn .ic-pause { display: none; }
.playbtn.is-playing .ic-play { display: none; }
.playbtn.is-playing .ic-pause { display: block; }

/* 2) Description in the middle */
.player-now { text-align: center; max-width: 100%; }
.player-chapter { font-size: 15.5px; font-weight: 680; color: var(--text); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.player-book { font-size: 12px; color: var(--gold); letter-spacing: .4px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* 3) Other controls below */
.player-controls { display: flex; align-items: center; justify-content: center; gap: 10px; }
.iconbtn {
  width: 46px; height: 46px; border-radius: 14px; cursor: pointer; position: relative;
  display: inline-grid; place-items: center;
  border: 1px solid var(--hairline); color: var(--blue-light);
  background: rgba(255,255,255,0.05);
  transition: background .15s ease, color .15s ease, transform .06s ease, border-color .15s ease;
}
.iconbtn:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: var(--hairline-2); }
.iconbtn:active { transform: scale(.92); }
.iconbtn.skip { position: relative; }
.iconbtn.skip .skip-ring { transform: translateY(1px); }
.iconbtn.skip .skip-num {
  position: absolute; top: 56%; left: 50%; transform: translate(-50%, -50%);
  font-size: 8.5px; font-weight: 700; letter-spacing: -0.3px; pointer-events: none;
}
.iconbtn-toggle[aria-pressed="true"] {
  background: linear-gradient(150deg, var(--gold-hi), var(--gold-lo)); color: #2a1d02; border-color: transparent;
}

/* 4) Seek bar + time at bottom */
.player-progress { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 2px; }
.player-progress .time { flex: 0 0 auto; width: 38px; color: var(--muted); font-size: 11.5px;
  font-variant-numeric: tabular-nums; text-align: center; }
#seek {
  flex: 1 1 auto; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 6px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--gold) var(--p,0%), rgba(255,255,255,0.12) var(--p,0%));
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold-hi); box-shadow: 0 0 0 4px rgba(233,196,94,0.20); cursor: pointer;
}
#seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--gold-hi); cursor: pointer; }

@media (max-width: 480px) {
  .player { padding: 16px 14px 18px; gap: 11px; }
  .player-controls { gap: 7px; }
  .playbtn { width: 60px; height: 60px; }
  .iconbtn { width: 44px; height: 44px; }
  .site-title { font-size: 25px; }
}

/* Thin phones: shrink the controls so all six buttons fit on one row. */
@media (max-width: 380px) {
  .player { padding: 14px 10px 16px; gap: 9px; }
  .player-controls { gap: 5px; }
  .iconbtn { width: 38px; height: 38px; border-radius: 11px; }
  .iconbtn svg { width: 19px; height: 19px; }
  .iconbtn.skip .skip-ring { width: 25px; height: 25px; }
  .iconbtn.skip .skip-num { font-size: 8px; }
  .playbtn { width: 54px; height: 54px; }
  .player-progress .time { width: 34px; font-size: 11px; }
}

@media (max-width: 320px) {
  .player-controls { gap: 3px; }
  .iconbtn { width: 34px; height: 34px; border-radius: 10px; }
  .iconbtn svg { width: 17px; height: 17px; }
  .iconbtn.skip .skip-ring { width: 23px; height: 23px; }
  .playbtn { width: 50px; height: 50px; }
}
