:root {
  color-scheme: dark;
  --bg: #050607;
  --bg-soft: #101317;
  --surface: rgba(16, 19, 23, 0.82);
  --surface-solid: #11151a;
  --text: #f3efe6;
  --muted: #9da3aa;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #d8ad59;
  --accent-2: #47dbe8;
  --accent-rgb: 216, 173, 89;
  --danger: #ff7d75;
  --shadow: 0 35px 90px rgba(0, 0, 0, 0.45);
  --font-display: "Ysabeau SC", ui-sans-serif, system-ui, sans-serif;
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-horizons {
  color-scheme: light;
  --bg: #f4f1e9;
  --bg-soft: #e9eef0;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-solid: #fdfcf8;
  --text: #0d2538;
  --muted: #5f6c72;
  --line: rgba(13, 37, 56, 0.14);
  --accent: #1479a8;
  --accent-2: #d9913d;
  --accent-rgb: 20, 121, 168;
  --danger: #a32626;
  --shadow: 0 35px 90px rgba(22, 55, 72, 0.18);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 10%, rgba(var(--accent-rgb), 0.13), transparent 34rem),
    radial-gradient(circle at 88% 18%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.35), transparent 72%);
  content: "";
  opacity: 0.22;
  pointer-events: none;
}

button, input, select { font: inherit; }
button, select, input[type="range"] { accent-color: var(--accent); }
button, select { color: inherit; }

.site-mark {
  display: flex;
  justify-content: space-between;
  width: min(1320px, calc(100% - 64px));
  margin: 0 auto;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-mark__meta { color: var(--muted); }

.page-shell {
  width: min(1320px, calc(100% - 64px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.player-stage {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(420px, 1.14fr);
  gap: clamp(42px, 7vw, 112px);
  align-items: center;
  min-height: min(760px, calc(100svh - 120px));
}

.book-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 580px;
  isolation: isolate;
}

.book-visual__orbit,
.book-visual__orbit::before,
.book-visual__orbit::after {
  position: absolute;
  width: min(42vw, 490px);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  content: "";
}

.book-visual__orbit::before { inset: 9%; width: auto; }
.book-visual__orbit::after { inset: 23%; width: auto; border-color: rgba(var(--accent-rgb), 0.36); }

.book-cover-wrap {
  position: relative;
  z-index: 2;
  width: min(66%, 330px);
  aspect-ratio: 0.67;
  overflow: hidden;
  background: #111;
  box-shadow: var(--shadow);
  transform: perspective(900px) rotateY(-5deg) rotateX(1deg);
  transition: transform 500ms ease, box-shadow 500ms ease;
}

.book-cover-wrap::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, rgba(255,255,255,.18), transparent 24%, transparent 78%, rgba(0,0,0,.2));
  content: "";
  pointer-events: none;
}

.is-playing .book-cover-wrap {
  box-shadow: 0 40px 110px rgba(var(--accent-rgb), 0.34);
  transform: perspective(900px) rotateY(0) rotateX(0) translateY(-4px);
}

.book-cover { display: block; width: 100%; height: 100%; object-fit: cover; }

.equalizer {
  position: absolute;
  z-index: 3;
  right: 8%;
  bottom: 10%;
  display: flex;
  gap: 4px;
  align-items: flex-end;
  width: 72px;
  height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  backdrop-filter: blur(12px);
}

.equalizer span {
  flex: 1;
  height: 22%;
  background: var(--accent);
  transform-origin: bottom;
}

.is-playing .equalizer span { animation: equalize 760ms ease-in-out infinite alternate; }
.is-playing .equalizer span:nth-child(2) { animation-delay: -510ms; }
.is-playing .equalizer span:nth-child(3) { animation-delay: -280ms; }
.is-playing .equalizer span:nth-child(4) { animation-delay: -640ms; }
.is-playing .equalizer span:nth-child(5) { animation-delay: -160ms; }

@keyframes equalize { to { height: 100%; } }

.player-panel { min-width: 0; padding: 36px 0; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.book-title {
  max-width: 850px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(48px, 6vw, 92px);
  font-weight: 400;
  line-height: 0.86;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.book-author {
  margin: 17px 0 56px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.now-playing { min-height: 98px; }

.now-playing__kind {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.now-playing__title {
  display: block;
  max-width: 780px;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 500;
  line-height: 1.08;
  text-wrap: balance;
}

.resume-panel {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.09);
}

.resume-panel[hidden] { display: none; }
.resume-panel p { margin: 0; font-size: 14px; }
.resume-panel__actions { display: flex; gap: 8px; }

.text-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.text-button--primary { border-color: var(--accent); background: var(--accent); color: var(--bg); }

.timeline { margin-top: 28px; }
.timeline__times { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }

.seek {
  width: 100%;
  height: 46px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
.seek::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(90deg, var(--accent) var(--seek-progress, 0%), var(--line) var(--seek-progress, 0%)); }
.seek::-moz-range-track { height: 3px; background: var(--line); }
.seek::-moz-range-progress { height: 3px; background: var(--accent); }
.seek::-webkit-slider-thumb { width: 15px; height: 15px; margin-top: -6px; appearance: none; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.seek::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); }
.is-scrubbing .seek { cursor: grabbing; }
.is-scrubbing .seek::-webkit-slider-thumb { transform: scale(1.2); }
.is-scrubbing .seek::-moz-range-thumb { transform: scale(1.2); }

.main-controls { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 25px 0; }
.control-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.control-button:hover:not(:disabled) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); transform: translateY(-2px); }
.control-button:disabled { opacity: .3; cursor: default; }
.control-button--play { width: 76px; height: 76px; border: 0; background: var(--text); color: var(--bg); font-size: 25px; box-shadow: 0 10px 38px rgba(var(--accent-rgb), .22); }
.control-button--play:hover { background: var(--accent); }
.control-button--jump { font-size: 12px; font-weight: 800; }
.control-button--skip { font-size: 18px; }

.utility-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.utility-control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.utility-control select,
.volume-wrap {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
}
.volume-wrap { display: flex; align-items: center; }
.volume-wrap input { width: 100%; }

.player-status { min-height: 20px; margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.player-status.is-error { color: var(--danger); }

.book-progress { position: relative; height: 2px; margin-top: 32px; background: var(--line); }
.book-progress::before { position: absolute; inset: 0 auto 0 0; width: var(--book-progress, 0%); background: var(--accent-2); content: ""; }
.book-progress span { position: absolute; top: 10px; right: 0; color: var(--muted); font-size: 11px; }

.chapters-section {
  margin-top: 70px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}
.chapters-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.chapters-header h2 { margin: 0; font-family: var(--font-display); font-size: clamp(34px, 4vw, 58px); font-weight: 400; letter-spacing: -.025em; }
.chapters-header span { color: var(--muted); font-size: 13px; }

.chapter-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; padding: 0; background: var(--line); list-style: none; }
.chapter-row {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 88px;
  padding: 15px 18px;
  overflow: hidden;
  border: 0;
  background: var(--surface-solid);
  text-align: left;
  cursor: pointer;
}
.chapter-row::after { position: absolute; inset: auto 0 0; width: var(--row-progress, 0%); height: 2px; background: var(--accent); content: ""; }
.chapter-row:hover, .chapter-row.is-current { z-index: 1; outline: 1px solid var(--accent); outline-offset: -1px; }
.chapter-row.is-current { background: color-mix(in srgb, var(--surface-solid) 86%, var(--accent)); }
.chapter-row__number { color: var(--muted); font-family: var(--font-display); font-size: 18px; }
.chapter-row__copy { min-width: 0; }
.chapter-row__kind { display: block; margin-bottom: 4px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.chapter-row__title { display: block; overflow: hidden; font-size: 15px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.chapter-row__duration { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.page-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--font-display); font-size: 12px; letter-spacing: .08em; }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }

@media (max-width: 980px) {
  .site-mark, .page-shell { width: min(100% - 36px, 760px); }
  .player-stage { grid-template-columns: 1fr; gap: 24px; min-height: 0; }
  .book-visual { min-height: 440px; }
  .book-visual__orbit { width: min(76vw, 420px); }
  .book-cover-wrap { width: min(48vw, 270px); }
  .equalizer { right: 18%; }
  .player-panel { padding-top: 0; }
  .book-title { font-size: clamp(52px, 12vw, 82px); }
  .book-author { margin-bottom: 38px; }
  .chapter-list { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-mark { width: calc(100% - 28px); padding-top: 18px; font-size: 12px; }
  .site-mark__meta { display: none; }
  .page-shell { width: calc(100% - 28px); padding: 22px 0 calc(34px + env(safe-area-inset-bottom)); }
  .book-visual { min-height: 335px; }
  .book-cover-wrap { width: min(48vw, 195px); }
  .equalizer { right: 10%; bottom: 7%; }
  .book-title { font-size: clamp(47px, 15vw, 68px); line-height: .9; }
  .book-author { margin: 12px 0 34px; font-size: 18px; }
  .now-playing { min-height: 82px; }
  .now-playing__title { font-size: 27px; }
  .resume-panel { align-items: stretch; flex-direction: column; }
  .resume-panel__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .main-controls { position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 10; gap: 8px; margin: 22px -5px; padding: 9px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface-solid) 88%, transparent); box-shadow: 0 18px 42px rgba(0,0,0,.2); backdrop-filter: blur(18px); }
  .control-button { width: 47px; height: 47px; }
  .control-button--play { width: 64px; height: 64px; }
  .utility-controls { grid-template-columns: 1fr 1fr; }
  .utility-control--volume { display: none; }
  .chapters-section { margin-top: 48px; }
  .chapters-header { align-items: start; flex-direction: column; gap: 6px; }
  .chapter-row { min-height: 82px; padding-inline: 12px; }
  .chapter-row__title { white-space: normal; }
  .page-footer { flex-direction: column; }
}

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