/* Hinterland web player. Mirrors HinterlandStyle.swift and the iOS views. */

:root {
  color-scheme: light dark;
  --paper: #FBF7F1;
  --surface: #FFFEFA;
  --ink: #27221E;
  --ink-2: #6E6157;
  --accent: #B8300E;
  --on-accent: #FFFFFF;
  --orange: #F57838;
  --danger: #C4211A;
  --hairline: rgb(60 50 40 / 0.14);
  --pressed: rgb(39 34 30 / 0.05);
  --glass-shadow: 0 6px 20px rgb(60 40 20 / 0.09), 0 1px 2px rgb(60 40 20 / 0.06);
  --backdrop: rgb(30 22 16 / 0.32);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", Georgia, serif;
  --mono-digits: tabular-nums;
  --page-x: 16px;
  --radius-card: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B1A19;
    --surface: #2A2826;
    --ink: #F6F0E7;
    --ink-2: #BDB5AB;
    --accent: #FF945C;
    /* White text on the light dark-mode accent is too faint for words; buttons with
       text use deep ink instead. The play glyph stays white, as in the app. */
    --on-accent: #1B1A19;
    --danger: #FF6B5E;
    --hairline: rgb(246 240 231 / 0.13);
    --pressed: rgb(246 240 231 / 0.06);
    --glass-shadow: 0 6px 20px rgb(0 0 0 / 0.35), 0 0 0 0.5px rgb(246 240 231 / 0.08);
    --backdrop: rgb(0 0 0 / 0.55);
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  font: 17px/1.45 var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.has-mini { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
body:has(dialog[open]) { overflow: hidden; }

/* The player replaces everything else on the page while it is open. */
body.view-player { padding-bottom: 0; }
body.view-player .app,
body.view-player .content,
body.view-player .site-footer,
body.view-player .skip-link,
body.view-player #mini { display: none !important; }

[hidden] { display: none !important; }

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; }
.icon { flex-shrink: 0; }

a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }

.serif {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.005em;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--glass-shadow);
}
.skip-link:focus { top: max(12px, env(safe-area-inset-top)); }

/* ---------- app area ---------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 88vh;
  min-height: 88svh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 max(var(--page-x), env(safe-area-inset-right)) 24px max(var(--page-x), env(safe-area-inset-left));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: max(12px, env(safe-area-inset-top));
}

.glass-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--glass-shadow);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.glass-button:focus-visible { border-radius: 50%; outline-offset: 3px; }
.glass-button:active { transform: scale(0.94); }

.large-title {
  margin: 14px 0 6px 2px;
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}

#library {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 440px;
}

.unavailable {
  max-width: 440px;
  margin: auto;
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-2);
}

/* Empty library: LibraryView.emptyLibrary */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 42px 14px 56px;
  text-align: center;
}
.empty img { width: 172px; height: 172px; }
.empty h2 {
  font-size: 34px;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}
.empty-lead { font-size: 20px; line-height: 25px; font-weight: 600; }
.empty-body { color: var(--ink-2); text-wrap: pretty; }
.empty .hint { font-size: 13px; line-height: 18px; color: var(--ink-2); }

.prominent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.prominent .icon { stroke-width: 2.4; }
.prominent:focus-visible { border-radius: 999px; outline-offset: 3px; }
.prominent:active { transform: scale(0.985); filter: brightness(0.92); }
@media (hover: hover) { .prominent:hover { filter: brightness(1.06); } }

/* Library list: LibraryView.bookList */
.book-list {
  width: 100%;
  max-width: 760px;
  margin: 12px auto 0;
}

.section-header,
.group-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.book-list ul {
  background: var(--surface);
  border-radius: 26px;
  padding: 4px 0;
}
.book-list li { position: relative; display: flex; align-items: center; }
.book-list li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 97px;
  right: 0;
  border-top: 0.5px solid var(--hairline);
}

.book-row {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 92px;
  padding: 12px 6px 12px 16px;
  text-align: left;
  border-radius: 20px;
}
.book-row > .icon { color: var(--ink-2); stroke-width: 2.4; }
.book-row:focus-visible, .row-more:focus-visible { outline-offset: -3px; }

.book-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.book-title {
  font-weight: 600;
  line-height: 22px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.book-author, .book-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-2);
}
.book-author { font-size: 15px; line-height: 20px; }
.book-meta { font-size: 12px; line-height: 16px; }

.row-more {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  margin-right: 6px;
  border-radius: 50%;
  color: var(--ink-2);
}

.section-footer {
  padding: 8px 20px 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

@media (hover: hover) {
  .book-row:hover, .row-more:hover, .content-row:hover, .row[href]:hover, .action:hover, .option-row:hover, .menu:hover {
    background-color: var(--pressed);
  }
}
.book-row:active, .row-more:active, .content-row:active, .row[href]:active, .action:active, .option-row:active, .menu:active {
  background-color: var(--pressed);
}

/* Artwork: BookArtwork. Size and radius arrive inline from app.js. */
.artwork {
  display: block;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.artwork img { width: 100%; height: 100%; object-fit: cover; }
.artwork.placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgb(245 120 56 / 0.92), #B03820);
}
.artwork.placeholder svg { width: 40%; height: 40%; }

/* ---------- mini player: MiniPlayerView ---------- */

.mini {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}

.mini-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 660px;
  margin: 0 auto;
  padding: 7px 7px 7px 10px;
  border-radius: 17px;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.08);
}

.mini-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  text-align: left;
  border-radius: 12px;
}
.mini-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-title, .mini-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-title { font-size: 15px; line-height: 20px; font-weight: 600; }
.mini-sub { font-size: 12px; line-height: 16px; color: var(--ink-2); }

.mini-play {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--accent);
}
.mini-play svg { width: 21px; height: 21px; }
.mini-play[aria-label="Play"] svg { transform: translateX(1px); }
.mini-play:disabled { opacity: 0.35; }
.mini-play:focus-visible { border-radius: 50%; }
.mini-open:focus-visible { outline-offset: 0; }

.mini-progress {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 2px;
  pointer-events: none;
}
.mini-progress span {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.25s linear;
}

/* ---------- sheets ---------- */

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper);
  max-width: none;
  max-height: none;
  overscroll-behavior: contain;
}
dialog::backdrop { background: var(--backdrop); }

/* Full sheets: bottom sheets on phones, centred cards on wide screens. */
dialog.sheet {
  width: 100%;
  height: calc(100% - max(10px, env(safe-area-inset-top)));
  margin: auto 0 0;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgb(0 0 0 / 0.12);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet.compact { height: auto; max-height: calc(100% - max(10px, env(safe-area-inset-top))); }

@media (min-width: 700px) and (min-height: 560px) {
  dialog.sheet {
    width: min(560px, 100% - 48px);
    height: auto;
    max-height: min(880px, 100% - 64px);
    margin: auto;
    border-radius: 24px;
    box-shadow: 0 24px 70px rgb(0 0 0 / 0.22);
  }
  dialog.sheet.compact { max-height: min(880px, 100% - 64px); }
}

#rename-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.sheet-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 64px;
  padding: 12px 16px 6px;
}
.bar-end { justify-self: end; }
.bar-start { justify-self: start; }
.sheet-title {
  font-size: 17px;
  line-height: 22px;
  font-weight: 600;
  text-align: center;
}
.sheet-title.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.bar-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 17px;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--glass-shadow);
  white-space: nowrap;
}
.bar-button.strong { font-weight: 600; }
.bar-button:disabled { color: var(--ink-2); opacity: 0.55; box-shadow: none; }
.bar-button:focus-visible { border-radius: 999px; }
.bar-button:not(:disabled):active { transform: scale(0.96); }

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
}

/* Grouped list sections, as in the iOS Forms */
.group { margin-bottom: 26px; }
.group:last-child { margin-bottom: 0; }
.group-header label { cursor: default; }
#review-count {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-variant-numeric: var(--mono-digits);
}
.group-footer {
  padding: 8px 20px 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}
.group-footer:empty { display: none; }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
}
.card > li + li { border-top: 0.5px solid var(--hairline); margin-left: 20px; }
.card > li + li > .row { margin-left: -20px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 20px;
  color: var(--ink);
  text-decoration: none;
  border-radius: inherit;
}
a.row { border-radius: var(--radius-card); }
.card > li + li > a.row { border-radius: 0 0 var(--radius-card) var(--radius-card); }
.card > li:first-child:not(:last-child) > a.row { border-radius: var(--radius-card) var(--radius-card) 0 0; }
a.row:focus-visible { outline-offset: -3px; }
.row .chevron { color: var(--ink-2); opacity: 0.7; }
.row-value { color: var(--ink-2); font-variant-numeric: var(--mono-digits); text-align: right; }

.field {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-card);
  font: inherit;
  color: var(--ink);
  background: transparent;
}
.field::placeholder { color: var(--ink-2); opacity: 0.7; }
.field:focus-visible { outline-offset: -3px; border-radius: var(--radius-card); }

/* Import review */
.review-list:empty { display: none; }
.review-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 6px 4px 12px;
}
.review-list li + li { border-top: 0.5px solid var(--hairline); }
.order {
  flex-shrink: 0;
  width: 24px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: var(--mono-digits);
  color: var(--accent);
}
.review-name { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 22px; padding: 6px 0; }
.movers { display: flex; flex-shrink: 0; }
.movers button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--accent);
}
.movers button:disabled { color: var(--ink-2); opacity: 0.3; }
@media (hover: hover) { .movers button:not(:disabled):hover { background: var(--pressed); } }

.status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 20px 16px;
  margin-bottom: 10px;
  font-size: 15px;
  color: var(--ink-2);
}

progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  color: var(--accent);
  background: var(--hairline);
}
progress::-webkit-progress-bar { background: var(--hairline); border-radius: 2px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; transition: width 0.25s linear; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }

.error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--danger);
  font-size: 15px;
  line-height: 20px;
}
.error .icon { margin-top: -1px; }

/* Settings */
.coffee {
  margin-top: 28px;
  padding: 0 20px;
  font-size: 13px;
  line-height: 19px;
  color: var(--ink-2);
  text-align: center;
  text-wrap: pretty;
}
.coffee-link { color: var(--accent); font-weight: 500; }

/* ---------- player view: PlayerView as a full page ---------- */

.player-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

.player-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: max(10px, env(safe-area-inset-top)) max(var(--page-x), env(safe-area-inset-right)) 8px max(var(--page-x), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 16px 0 10px;
}

.player-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 max(var(--page-x), env(safe-area-inset-right)) calc(36px + env(safe-area-inset-bottom)) max(var(--page-x), env(safe-area-inset-left));
}

#player-body {
  width: 100%;
  max-width: 460px;
  padding: 0 10px;
}
.player-view .unavailable { padding-top: 80px; }

#contents {
  width: 100%;
  max-width: 560px;
  margin-top: 36px;
  scroll-margin-top: 80px;
}
#contents:has(#contents-body:empty) { display: none; }
.contents-heading {
  padding: 0 4px 14px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
}

/* Two columns on wide screens: the player on the left, the contents beside it. */
@media (min-width: 900px) {
  .player-view { height: 100vh; height: 100svh; }
  .player-bar { position: static; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .player-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: clamp(32px, 5vw, 80px);
    align-items: stretch;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 max(32px, env(safe-area-inset-right)) 0 max(32px, env(safe-area-inset-left));
  }
  #player-body {
    justify-self: center;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 0 6px 32px;
  }
  /* Centres the player vertically without clipping it when the window is short. */
  #player-body > :first-child { margin-top: auto; }
  #player-body > :last-child { margin-bottom: auto; }
  #player-body .player-head .artwork {
    width: clamp(205px, 34vh, 290px) !important;
    height: clamp(205px, 34vh, 290px) !important;
    border-radius: calc(clamp(205px, 34vh, 290px) * 0.17) !important;
  }
  #contents {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 8px 0 24px;
  }
  #contents-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 8px;
  }
  .option-row[data-action="contents"] { display: none; }
}

.player-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.player-head .artwork {
  margin: 12px 0 14px;
  box-shadow: 0 12px 22px rgb(39 34 30 / 0.15);
}
.player-title {
  font-size: 28px;
  line-height: 34px;
  color: var(--ink);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.player-author { font-size: 15px; line-height: 20px; color: var(--ink-2); }

.notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-top: 24px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--accent);
  text-align: center;
}
.notice-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.notice-title .icon { stroke-width: 2.4; }
.link {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.link:focus-visible { border-radius: 999px; }

.track-detail {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 35px 0 18px;
  text-align: center;
}
.track-title {
  font-weight: 600;
  line-height: 22px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.track-sub { font-size: 15px; line-height: 20px; color: var(--ink-2); overflow-wrap: anywhere; }

.scrubber input[type="range"] {
  display: block;
  width: 100%;
  height: 44px;
  margin: -8px 0 -6px;
  accent-color: var(--accent);
  cursor: pointer;
  background: transparent;
}
.scrubber input[type="range"]:disabled { cursor: default; opacity: 0.5; }
.scrubber input[type="range"]:focus-visible { outline-offset: -4px; border-radius: 12px; }

.times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: var(--mono-digits);
  color: var(--ink-2);
}

.transport {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  padding: 19px 0 31px;
  color: var(--ink);
}

.skip {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  transition: transform 0.15s ease;
}
.skip:not(:disabled):active { transform: scale(0.92); }
.skip:focus-visible, .play:focus-visible { border-radius: 50%; }
.skip:disabled { opacity: 0.35; }

.skip-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
}
.skip-icon svg { width: 44px; height: 44px; stroke-width: 1.45; }
.skip-icon > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 1px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: var(--mono-digits);
  line-height: 1;
}

.play {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  color: #FFFFFF;
  background: var(--accent);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.play svg { width: 27px; height: 27px; }
.play[aria-label="Play"] svg { transform: translateX(2px); }
.play:not(:disabled):active { transform: scale(0.95); filter: brightness(0.92); }
.play:disabled { opacity: 0.45; }
.play:disabled:has(.spinner) { opacity: 1; }

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid rgb(255 255 255 / 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overall {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 24px;
}
.overall-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
}
#overall-percent { font-variant-numeric: var(--mono-digits); }

.options {
  padding: 0 18px;
  border-radius: 18px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% + 36px);
  min-height: 54px;
  margin: 0 -18px;
  padding: 0 18px;
  border-bottom: 0.5px solid var(--hairline);
  border-radius: 18px 18px 0 0;
  text-align: left;
}
.option-row:focus-visible { outline-offset: -3px; border-radius: 18px 18px 0 0; }
.option-pair {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 56px;
}

/* The native <select> covers its label invisibly so the system menu opens on click. */
.menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 -10px;
  padding: 0 10px;
  border-radius: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.menu select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  font-size: 16px; /* keeps iOS Safari from zooming */
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.menu:has(select:focus-visible) { outline: 3px solid var(--accent); outline-offset: 0; }

/* ---------- chapters & tracks: BookContentsView ---------- */

#contents-body .section-header { padding-top: 6px; }
#contents-body .section-header:not(:first-child) { margin-top: 24px; }

.plain-list {
  background: var(--surface);
  border-radius: var(--radius-card);
}
.plain-list li + li { border-top: 0.5px solid var(--hairline); margin-left: 55px; }
.plain-list li + li .content-row { margin-left: -55px; width: calc(100% + 55px); padding-left: 16px; }

.content-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 16px;
  text-align: left;
  border-radius: 0;
}
.plain-list li:first-child .content-row { border-radius: var(--radius-card) var(--radius-card) 0 0; }
.plain-list li:last-child .content-row { border-radius: 0 0 var(--radius-card) var(--radius-card); }
.plain-list li:only-child .content-row { border-radius: var(--radius-card); }
.content-row:focus-visible { outline-offset: -3px; }
.content-row .accent { display: grid; place-items: center; width: 27px; color: var(--accent); flex-shrink: 0; }
.content-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.content-title { line-height: 22px; overflow-wrap: anywhere; }
.content-row.current .content-title { font-weight: 600; }
.content-sub { font-size: 12px; line-height: 16px; color: var(--ink-2); }
.content-row.chapter { min-height: 46px; padding-top: 6px; padding-bottom: 6px; }
.content-row.chapter .content-title { flex: 1; min-width: 0; font-size: 15px; line-height: 20px; }
.dot {
  flex-shrink: 0;
  width: 27px;
  height: 5px;
  background: radial-gradient(circle, var(--orange) 2.5px, transparent 3px);
}
.content-time {
  flex-shrink: 0;
  font-size: 12px;
  font-variant-numeric: var(--mono-digits);
  color: var(--ink-2);
}

/* ---------- action sheets (add, actions, delete) ---------- */

dialog.action-sheet {
  width: calc(100% - 16px);
  max-width: 420px;
  margin: auto auto calc(8px + env(safe-area-inset-bottom));
  background: transparent;
  overflow: visible;
}
dialog.action-sheet[open] { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 700px) and (min-height: 560px) {
  dialog.action-sheet { width: 380px; margin: auto; }
}

.action-group {
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.16);
}
.action-head {
  padding: 16px 20px 14px;
  text-align: center;
  border-bottom: 0.5px solid var(--hairline);
}
.action-head h2 {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.action-head p {
  margin-top: 4px;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}
.action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 8px 20px;
  font-size: 19px;
  color: var(--accent);
  border-radius: 0;
}
.action + .action { border-top: 0.5px solid var(--hairline); }
.action-group .action:last-child { border-radius: 0 0 20px 20px; }
.action.destructive { color: var(--danger); }
.action.cancel {
  font-weight: 600;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.16);
}
.action:focus-visible { outline-offset: -3px; }
.action.cancel:focus-visible { border-radius: 20px; }
.action-group .action:last-child:focus-visible { border-radius: 0 0 20px 20px; }
.action-note {
  padding: 4px 16px 0;
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.4);
}
@media (hover: none) { .action-note { display: none; } }

/* ---------- alert ---------- */

dialog.alert {
  width: min(300px, 100% - 48px);
  margin: auto;
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 16px 50px rgb(0 0 0 / 0.2);
}
.alert h2 { padding: 20px 18px 0; font-size: 17px; line-height: 22px; font-weight: 600; }
.alert p { padding: 6px 18px 18px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.alert-button {
  width: 100%;
  min-height: 48px;
  border-top: 0.5px solid var(--hairline);
  border-radius: 0 0 20px 20px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
}
.alert-button:focus-visible { outline-offset: -3px; border-radius: 0 0 20px 20px; }

/* ---------- drag and drop ---------- */

.drop-hint {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
body.dragging .drop-hint { display: grid; }
.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(460px, 100%);
  padding: 44px 28px;
  border: 2px dashed var(--accent);
  border-radius: 28px;
  background: var(--surface);
  text-align: center;
  color: var(--ink-2);
  font-size: 15px;
}
.drop-card .icon { width: 44px; height: 44px; padding: 7px; border-radius: 50%; color: var(--on-accent); background: var(--accent); stroke-width: 2.4; }
.drop-title { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 30px; color: var(--ink); }

/* ---------- page content below the app ---------- */

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px max(24px, env(safe-area-inset-right)) 32px max(24px, env(safe-area-inset-left));
  border-top: 1px solid var(--hairline);
}
.content h1 {
  font-size: clamp(30px, 6vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.lead {
  margin-top: 16px;
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}
.content section { margin-top: 56px; }
.content h2 { font-size: 26px; line-height: 1.2; margin-bottom: 16px; }
.content h3 { font-size: 17px; line-height: 22px; font-weight: 600; }
.content section > p { line-height: 1.6; color: var(--ink-2); text-wrap: pretty; }
.content section > p + p { margin-top: 12px; }
.content li p { margin-top: 4px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }

.steps { display: grid; gap: 12px; counter-reset: step; }
.steps li {
  position: relative;
  padding: 18px 20px 18px 66px;
  border-radius: var(--radius-card);
  background: var(--surface);
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 18px;
  top: 17px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 15px;
  color: var(--on-accent);
  background: var(--accent);
}

.features { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.features li {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--surface);
}

.formats { display: grid; gap: 1px; margin-bottom: 16px; border-radius: var(--radius-card); overflow: hidden; background: var(--hairline); }
.formats div { display: flex; align-items: baseline; gap: 16px; padding: 14px 20px; background: var(--surface); }
.formats dt { flex-shrink: 0; width: 48px; font-weight: 700; color: var(--accent); font-variant-numeric: var(--mono-digits); }
.formats dd { color: var(--ink-2); font-size: 15px; }

.download {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--glass-shadow);
}
.download:focus-visible { border-radius: 999px; }

.faq { border-radius: var(--radius-card); background: var(--surface); }
.faq details + details { border-top: 0.5px solid var(--hairline); margin-left: 20px; }
.faq details + details summary { margin-left: -20px; }
.faq summary {
  position: relative;
  display: block;
  min-height: 52px;
  padding: 14px 52px 14px 20px;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-card);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 22px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-2);
  border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.faq details[open] summary::after { transform: translateY(3px) rotate(225deg); }
.faq summary:focus-visible { outline-offset: -3px; }
.faq details p { padding: 0 20px 18px; color: var(--ink-2); line-height: 1.6; }
@media (hover: hover) { .faq summary:hover { background: var(--pressed); } }

.content > .coffee { margin-top: 56px; font-size: 15px; line-height: 22px; }

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px max(24px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
}
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
.site-footer p { margin-top: 6px; letter-spacing: 0.04em; }

/* ---------- widths ---------- */

@media (max-width: 380px) {
  :root { --page-x: 12px; }
  .large-title { font-size: 30px; line-height: 36px; }
  .empty h2 { font-size: 30px; }
  .transport { gap: 18px; }
  .options { padding: 0 14px; }
  .option-row { width: calc(100% + 28px); margin: 0 -14px; padding: 0 14px; }
  .menu { gap: 7px; }
  .steps li { padding-left: 60px; }
}

@media (min-width: 700px) {
  :root { --page-x: 24px; }
  .empty { padding-top: 24px; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  dialog.sheet[open] { animation: sheet-in 0.36s cubic-bezier(0.2, 0.85, 0.25, 1); }
  dialog.action-sheet[open] { animation: sheet-in 0.3s cubic-bezier(0.2, 0.85, 0.25, 1); }
  dialog.alert[open] { animation: pop-in 0.22s ease-out; }
  dialog[open]::backdrop { animation: fade-in 0.25s ease-out; }
  body.dragging .drop-hint { animation: fade-in 0.15s ease-out; }
  .player-view { animation: view-in 0.3s cubic-bezier(0.2, 0.85, 0.25, 1); }
  @media (min-width: 700px) and (min-height: 560px) {
    dialog.sheet[open], dialog.action-sheet[open] { animation: pop-in 0.24s ease-out; }
  }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes view-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- high contrast ---------- */

@media (forced-colors: active) {
  .play, .prominent, .glass-button, .bar-button, .action, .mini-card, .card, .plain-list { border: 1px solid ButtonText; }
}

/* === lead-owned additions below === */

/* ---------- mascot: the companion; app.js moves it with SVG transform attributes ---------- */
.mascot { display: block; overflow: visible; flex: none; -webkit-tap-highlight-color: transparent; user-select: none; }
.empty .mascot { margin: 0 auto; }

/* A small companion beside the page title, the app's signature. */
.large-title { display: flex; align-items: center; gap: 8px; }
.title-mascot { display: block; flex: none; width: 44px; height: 44px; margin: -2px 0; }

#review-status:not([hidden]) { display: flex; align-items: center; gap: 14px; }
#review-status .review-progress { flex: 1; min-width: 0; }
#review-status .review-progress p { margin: 0 0 8px; }
#review-status progress { width: 100%; }

/* ---------- mini player window (Document Picture-in-Picture) ---------- */
body.pip {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.pip-card { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 14px 18px 10px; }
.pip-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pip-artwork { appearance: none; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 12px; flex: none; line-height: 0; }
.pip-artwork:focus-visible, .pip button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pip-text { min-width: 0; }
.pip-title, .pip-sub { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pip-title { font-size: 16px; font-weight: 600; line-height: 21px; }
.pip-sub { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.pip-progress { height: 4px; border-radius: 2px; background: var(--hairline); overflow: hidden; margin-top: 6px; }
.pip-progress span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.pip-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pip-controls { display: flex; align-items: center; justify-content: center; gap: 22px; }
.pip-controls button { appearance: none; border: 0; background: none; color: var(--ink); cursor: pointer; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; padding: 0; }
.pip-controls button:disabled { opacity: 0.4; cursor: default; }
.pip-controls .skip-icon { transform: scale(0.82); }
.pip-controls .pip-play { color: var(--accent); }
.pip-controls .pip-play .icon { width: 32px; height: 32px; }
body.pip.pip-artwork-only .pip-card { padding: 0; align-items: center; }
body.pip.pip-artwork-only .pip-text,
body.pip.pip-artwork-only .pip-progress,
body.pip.pip-artwork-only .pip-times,
body.pip.pip-artwork-only .pip-controls { display: none; }
body.pip.pip-artwork-only .pip-head { justify-content: center; }
body.pip.pip-artwork-only .pip-artwork .artwork { width: min(100vw, 100vh) !important; height: min(100vw, 100vh) !important; border-radius: 0 !important; }

