:root {
  --bg: #15130f;
  --panel: #211e18;
  --panel-strong: #2a261f;
  --text: #f4efe4;
  --muted: #a8a092;
  --line: #3a352d;
  --accent: #e77b57;
  --accent-soft: #40281f;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% -10%, #3d2c20 0, transparent 34rem),
    var(--bg);
}

button, input { font: inherit; }
button { color: inherit; }

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px calc(42px + var(--safe-bottom));
}

.topbar,
.section-heading,
.sheet-heading,
.time-row,
.player-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { min-height: 44px; }
.eyebrow, .label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.icon-button,
.control,
.play-button,
.pill,
.chapter-button,
.sheet-option {
  border: 0;
  cursor: pointer;
}

.icon-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: transparent;
}

.icon-button svg,
.control svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

#sleep-badge {
  position: absolute;
  right: -2px;
  bottom: 1px;
  min-width: 19px;
  padding: 2px 5px;
  border-radius: 20px;
  background: var(--accent);
  color: #1b120f;
  font-size: 9px;
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: minmax(140px, 42%) 1fr;
  gap: clamp(22px, 6vw, 46px);
  align-items: end;
  padding: clamp(30px, 8vh, 66px) 4px 36px;
}

.cover-wrap { position: relative; }
.cover {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 22px 55px #000a;
}

.cover-glow {
  position: absolute;
  inset: 15% -10% -10%;
  background: #b96348;
  filter: blur(42px);
  opacity: .22;
}

.author {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 7vw, 54px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .98;
}

.status {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.player {
  padding: 25px clamp(18px, 4vw, 30px) 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 18px 60px #0004;
}

.now-playing { min-height: 59px; }
.now-playing h2 {
  margin: 7px 0 0;
  overflow: hidden;
  font-size: clamp(17px, 4.2vw, 22px);
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline { margin-top: 22px; }
#seek {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.time-row {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: 44px 54px 72px 54px 44px;
  gap: clamp(5px, 2vw, 13px);
  align-items: center;
  justify-content: center;
  margin: 22px 0;
}

.control {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: transparent;
}

.control.skip { background: var(--panel-strong); }
.control:disabled { opacity: .28; cursor: default; }
.play-button {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 9px 28px #0008;
}

.play-button svg { width: 29px; height: 29px; fill: currentColor; }
.pause-icon { display: none; }
.playing .play-icon { display: none; }
.playing .pause-icon { display: block; }

.player-options {
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 17px;
}

.player-options p {
  flex: 1;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  min-width: 56px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.chapters { padding-top: 40px; scroll-margin-top: 18px; }
.section-heading h2 { margin: 0; font-size: 24px; }
.section-heading span { color: var(--muted); font-size: 12px; }
#chapter-list { display: grid; gap: 9px; margin: 18px 0 0; padding: 0; list-style: none; }

.chapter-button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 76px;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  text-align: left;
}

.chapter-button.active {
  border-color: var(--line);
  background: var(--panel);
}

.chapter-number {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chapter-copy { min-width: 0; }
.chapter-name {
  display: block;
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-progress {
  display: block;
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--line);
}

.chapter-progress > i { display: block; width: 0; height: 100%; background: var(--accent); }
.chapter-duration { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

dialog {
  width: 100%;
  max-width: 720px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog::backdrop { background: #0009; backdrop-filter: blur(5px); }
.sheet-card {
  padding: 10px 20px calc(24px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--panel);
}

.sheet-handle { width: 40px; height: 4px; margin: 0 auto 10px; border-radius: 4px; background: var(--line); }
.sheet-heading h2 { margin: 0; font-size: 21px; }
.sheet-options { display: grid; gap: 8px; margin-top: 13px; }
.sheet-option {
  display: flex;
  min-height: 51px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-radius: 13px;
  background: var(--panel-strong);
  text-align: left;
}

.sheet-option.active { color: var(--accent); }
.sheet-option small { color: var(--muted); }

button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:active:not(:disabled) { transform: scale(.96); }

@media (max-width: 480px) {
  .app { padding-inline: 14px; }
  .hero { grid-template-columns: 42% 1fr; gap: 20px; padding-top: 25px; }
  .cover { border-radius: 6px; }
  h1 { font-size: clamp(27px, 8vw, 38px); }
  .player { border-radius: 21px; }
  .controls { grid-template-columns: 38px 48px 68px 48px 38px; gap: 5px; }
  .play-button { width: 68px; height: 68px; }
  .chapter-button { padding-inline: 9px; }
}

@media (max-width: 370px) {
  .hero { grid-template-columns: 1fr; align-items: center; text-align: center; }
  .cover-wrap { width: 52%; margin: 0 auto; }
  .status { display: none; }
}

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