:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #17242d;
  --panel-strong: #20333e;
  --text: #f5f7f2;
  --muted: #aab7b8;
  --accent: #f6c85f;
  --accent-strong: #ffda7a;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(246, 200, 95, 0.16), transparent 32rem),
    linear-gradient(180deg, #101820 0%, #14232b 48%, #0e171d 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 34rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0 1rem max(1.2rem, env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  gap: 1rem;
}

.sticky-player {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: 1rem;
  margin-inline: -1rem;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 0.65rem;
}

.now-playing {
  display: grid;
  grid-template-columns: 4.75rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding-top: 0.5rem;
}

.cover {
  width: 4.75rem;
  height: 4.75rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.35rem;
  object-fit: cover;
  box-shadow: 0 0.75rem 1.6rem rgba(0, 0, 0, 0.28);
}

.book-copy {
  min-width: 0;
}

.eyebrow,
.status {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0.18rem 0 0.25rem;
  font-size: clamp(1.05rem, 4.8vw, 1.45rem);
  line-height: 1.08;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  margin-top: 0.1rem;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  background: rgba(23, 36, 45, 0.92);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.compact-player .now-playing,
.compact-player .secondary-controls {
  display: none;
}

.compact-player {
  gap: 0;
}

.compact-player .player {
  gap: 0.55rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.5rem;
  box-shadow: 0 0.8rem 1.8rem rgba(0, 0, 0, 0.22);
}

.compact-player .controls {
  grid-template-columns: repeat(2, 2.65rem) 3.35rem repeat(2, 2.65rem);
  gap: 0.35rem;
}

.compact-player .icon-button {
  width: 2.65rem;
  height: 2.65rem;
}

.compact-player .play-button {
  width: 3.35rem;
  height: 3.35rem;
}

.compact-player .seek {
  height: 1.55rem;
}

.compact-player .seek::before {
  inset-block: 0.58rem;
}

.compact-player .seek-fill {
  top: 0.58rem;
}

.compact-player .seek-thumb {
  width: 0.95rem;
  height: 0.95rem;
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.seek {
  position: relative;
  width: 100%;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.seek::before {
  content: "";
  position: absolute;
  inset: 0.8rem 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.seek-fill {
  position: absolute;
  left: 0;
  top: 0.8rem;
  width: 0%;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--accent);
}

.seek-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 1.05rem;
  height: 1.05rem;
  border: 0.18rem solid #101820;
  border-radius: 999px;
  background: var(--accent-strong);
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

.seek:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 0.15rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, 3.25rem) 4.6rem repeat(2, 3.25rem);
  gap: 0.45rem;
  justify-content: center;
  align-items: center;
}

.icon-button,
.play-button {
  border: 0;
  color: var(--text);
  background: var(--panel-strong);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
}

.play-button {
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: #101820;
  box-shadow: 0 0.85rem 1.8rem rgba(246, 200, 95, 0.22);
}

.icon-button:active,
.play-button:active {
  transform: translateY(1px) scale(0.99);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

svg {
  width: 1.55rem;
  height: 1.55rem;
  fill: currentColor;
}

.play-button svg {
  width: 2rem;
  height: 2rem;
}

text {
  fill: currentColor;
  font-size: 0.55rem;
  font-weight: 800;
  text-anchor: middle;
}

.skip-icon text {
  dominant-baseline: middle;
}

.hidden {
  display: none;
}

.secondary-controls {
  display: grid;
  grid-template-columns: 1fr 6.5rem 6.5rem;
  gap: 0.75rem;
}

.select-control {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

select {
  min-width: 0;
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #0f1a21;
  color: var(--text);
  padding: 0 0.75rem;
}

.chapters {
  display: grid;
  gap: 0.5rem;
}

.chapter-row {
  min-height: 3.35rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: rgba(23, 36, 45, 0.82);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.85rem;
  align-items: center;
  padding: 0.35rem 0.45rem 0.35rem 0.75rem;
}

.chapter-button {
  min-width: 0;
  min-height: 2.65rem;
  border: 0;
  color: var(--text);
  background: transparent;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.chapter-number {
  width: 2rem;
  color: var(--accent-strong);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chapter-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-progress {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.chapter-cache-button {
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.chapter-cache-button svg {
  width: 1.15rem;
  height: 1.15rem;
}

.chapter-cache-button.cached {
  color: #f5f7f2;
}

.chapter-cache-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.chapter-row.active {
  border-color: rgba(246, 200, 95, 0.8);
  background: rgba(246, 200, 95, 0.12);
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 0.75rem;
  }

  .sticky-player {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
  }

  .now-playing {
    grid-template-columns: 4.35rem minmax(0, 1fr);
    gap: 0.6rem;
  }

  .cover {
    width: 4.35rem;
    height: 4.35rem;
  }

  .controls {
    grid-template-columns: repeat(2, 2.8rem) 4.1rem repeat(2, 2.8rem);
  }

  .icon-button {
    width: 2.8rem;
    height: 2.8rem;
  }

  .play-button {
    width: 4.1rem;
    height: 4.1rem;
  }

  .compact-player .controls {
    grid-template-columns: repeat(2, 2.45rem) 3.1rem repeat(2, 2.45rem);
  }

  .compact-player .icon-button {
    width: 2.45rem;
    height: 2.45rem;
  }

  .compact-player .play-button {
    width: 3.1rem;
    height: 3.1rem;
  }
}
