/* Audio knjige: a calm night look for bedtime listening. Phone first; desktop gets a chapter column. */
:root {
  --bg: #0b1230;
  --bg-deep: #060a1f;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4ecdc;
  --muted: #bdb8cf;
  --faint: #9592ad;
  --gold: #f4c869;
  --gold-2: #e5ab48;
  --on-gold: #2a1c02;
  --focus: #ffe3a3;
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0d1638 0%, var(--bg) 45%, var(--bg-deep) 100%) fixed, var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(76, 96, 190, 0.32), transparent 70%),
    url("/img/stars.svg") center top / 1440px auto no-repeat;
  opacity: 0.9;
}
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 12px; }
.icon { width: 24px; height: 24px; flex: none; }

.app {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter) 24px;
  padding-right: max(16px, env(safe-area-inset-right));
}
.loading { color: var(--muted); text-align: center; margin-top: 30vh; }
.foot {
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding-top: env(safe-area-inset-top);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand .icon { color: var(--gold); width: 22px; height: 22px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  min-width: 48px;
  padding: 0 14px 0 6px;
  margin-left: -6px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-size: 17px;
}
.back-link:hover { color: var(--text); background: var(--panel); }

/* ---------------------------------------------------------------- buttons */
.cta {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 10px 22px 10px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: var(--on-gold);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(229, 171, 72, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.cta:hover { box-shadow: 0 12px 34px rgba(229, 171, 72, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.cta:active { transform: scale(0.985); }
.cta:disabled { background: var(--panel-2); color: var(--muted); box-shadow: none; cursor: default; }
.cta-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(42, 28, 2, 0.12);
  flex: none;
}
.cta-icon .icon { width: 26px; height: 26px; }
.cta-text { display: flex; flex-direction: column; min-width: 0; }
.cta-action { font-size: 22px; font-weight: 700; line-height: 1.15; }
.cta-detail { font-size: 15px; font-weight: 500; opacity: 0.85; }
.cta-small { display: inline-flex; width: auto; min-height: 52px; padding: 0 26px; font-weight: 700; justify-content: center; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 16px;
}
.text-link:hover { color: var(--text); }
.text-link .icon { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- library */
.hero {
  display: grid;
  gap: 22px;
  justify-items: center;
  text-align: center;
  padding: 8px 0 12px;
}
.hero-cover {
  display: block;
  width: min(72vw, 300px);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.hero-body { display: grid; gap: 6px; width: 100%; max-width: 420px; justify-items: center; }
.eyebrow { margin: 0; color: var(--gold); font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; }
.book-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.15; }
.byline { margin: 0 0 8px; color: var(--muted); }
.hero .progress { width: 100%; margin: 4px 0 14px; }
.hero .cta { margin-bottom: 2px; }

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--gold); }

.shelf { margin-top: 28px; }
.shelf-title { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 12px; }
.shelf-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
.book-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  min-height: 108px;
}
.book-card:hover { background: var(--panel-2); }
.book-card img { width: 88px; height: 88px; border-radius: 10px; }
.card-body { display: grid; gap: 4px; min-width: 0; }
.card-title { font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.card-author, .card-state { color: var(--muted); font-size: 14px; }
.card-state { color: var(--gold); }

.notice { text-align: center; padding: 18vh 8px 0; display: grid; gap: 8px; justify-items: center; }
.notice h1 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0; }
.notice p { color: var(--muted); margin: 0 0 16px; }

/* ---------------------------------------------------------------- player */
.player { display: grid; gap: 28px; }
.deck {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  text-align: center;
}
.cover {
  width: min(64vw, 36vh, 340px);
  height: auto;
  aspect-ratio: 1;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.now { display: grid; gap: 2px; width: 100%; }
.now-label { margin: 0; color: var(--gold); font-size: 15px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.now-title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 25px; line-height: 1.2; text-wrap: balance; }
.now-book { margin: 2px 0 0; color: var(--muted); font-size: 15px; }

.scrub { width: 100%; }
.scrub input {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 48px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
.scrub input:disabled { cursor: default; opacity: 0.5; }
.scrub input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold) var(--fill), rgba(255, 255, 255, 0.16) var(--fill));
}
.scrub input::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); }
.scrub input::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--gold); }
.scrub input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 0;
  background: #fff4dc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.scrub input::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 0; background: #fff4dc; }
.scrub input:focus-visible { outline-offset: 0; }
.times { display: flex; justify-content: space-between; margin-top: -6px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  max-width: 380px;
}
.ctl {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.ctl .icon { width: 34px; height: 34px; }
.ctl-sm { width: 48px; height: 48px; color: var(--muted); }
.ctl-sm .icon { width: 26px; height: 26px; }
.ctl:hover:not(:disabled) { background: var(--panel); }
.ctl:active:not(:disabled) { transform: scale(0.94); }
.ctl:disabled { opacity: 0.3; cursor: default; }
.ctl-play {
  width: 80px;
  height: 80px;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: var(--on-gold);
  box-shadow: 0 10px 30px rgba(229, 171, 72, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  position: relative;
}
.ctl-play .icon { width: 36px; height: 36px; }
.ctl-play:hover:not(:disabled) { background: linear-gradient(180deg, #f8d384, var(--gold)); }
.ctl-play:disabled { background: var(--panel-2); color: var(--muted); box-shadow: none; opacity: 1; }
.ctl-play.is-buffering::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status { margin: 0; min-height: 0; color: var(--muted); font-size: 15px; }
.status:empty { display: none; }

.extras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 400px; }
.chip {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1px;
  min-height: 64px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip .icon { width: 22px; height: 22px; margin-bottom: 2px; }
.chip-label { font-size: 13px; line-height: 1.2; }
.chip-value { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.chip:hover { background: var(--panel-2); color: var(--text); }
.chip.is-on { border-color: rgba(244, 200, 105, 0.55); color: var(--gold); }
.chip.is-on .chip-value { color: var(--gold); }

.side { display: none; }

/* ---------------------------------------------------------------- chapter list */
.chapters { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ch {
  display: grid;
  grid-template-columns: 36px 1fr 28px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.ch:hover:not(:disabled) { background: var(--panel); }
.ch:disabled { cursor: default; }
.ch-n {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ch-text { display: grid; min-width: 0; }
.ch-title { font-size: 16px; line-height: 1.3; }
.ch-meta { font-size: 13px; color: var(--faint); }
.ch-state { display: grid; place-items: center; color: var(--gold); }
.ch-state .icon { width: 20px; height: 20px; }
.ch.is-soon .ch-title { color: var(--faint); }
.ch.is-soon .ch-n { background: transparent; border: 1px dashed var(--line); color: var(--faint); }
.ch.is-done .ch-n { background: rgba(244, 200, 105, 0.16); color: var(--gold); }
.ch.is-current { background: rgba(244, 200, 105, 0.12); box-shadow: inset 0 0 0 1px rgba(244, 200, 105, 0.4); }
.ch.is-current .ch-n { background: var(--gold); color: var(--on-gold); }
.ch.is-current .ch-title { color: var(--text); font-weight: 600; }
.bars .bar { transform-origin: 50% 100%; transform-box: fill-box; animation: bounce 1.1s ease-in-out infinite; }
.bars .b2 { animation-delay: -0.35s; }
.bars .b3 { animation-delay: -0.7s; }
@keyframes bounce { 0%, 100% { transform: scaleY(0.45); } 50% { transform: scaleY(1); } }

/* ---------------------------------------------------------------- sheet (dialog) */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  max-height: 86dvh;
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: #121a3e;
  color: var(--text);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: rise 0.22s ease-out; }
.sheet::backdrop { background: rgba(3, 6, 20, 0.6); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-inner { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 4px 20px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 22px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px calc(16px + env(safe-area-inset-bottom));
}
.sheet-hint { margin: 4px 8px 10px; color: var(--muted); font-size: 15px; }
.opts { display: grid; gap: 6px; }
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 18px;
  text-align: left;
  cursor: pointer;
}
.opt:hover { background: var(--panel-2); }
.opt[aria-pressed="true"] { border-color: rgba(244, 200, 105, 0.6); color: var(--gold); background: rgba(244, 200, 105, 0.1); }
.opt-off { color: var(--muted); }

/* ---------------------------------------------------------------- short phones */
@media (max-height: 700px) {
  .cover { width: min(56vw, 30vh, 340px); }
  .deck { gap: 10px; }
  .now-title { font-size: 22px; }
  .chip { min-height: 58px; padding: 6px 4px; }
}

/* ---------------------------------------------------------------- tablet and desktop */
@media (min-width: 720px) {
  .hero {
    grid-template-columns: 300px minmax(0, 420px);
    justify-content: center;
    align-items: center;
    gap: 44px;
    text-align: left;
    padding-top: 6vh;
  }
  .hero-cover { width: 300px; }
  .hero-body { justify-items: start; }
  .book-title { font-size: 40px; }
  .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@media (min-width: 960px) {
  .player {
    grid-template-columns: minmax(0, 460px) minmax(0, 420px);
    justify-content: center;
    align-items: start;
    gap: 56px;
    padding-top: 8px;
  }
  .deck { margin: 0; }
  .cover { width: min(320px, 40vh); }
  .chip-chapters { display: none; }
  .extras { grid-template-columns: repeat(2, 1fr); max-width: 300px; }
  .side {
    display: block;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 14px 10px 10px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.035);
  }
  .side-title { margin: 0 10px 8px; font-family: var(--serif); font-weight: 400; font-size: 22px; }
  .sheet { margin: auto; border-radius: 24px; border-bottom: 1px solid var(--line); max-width: 480px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
