:root {
  --bg: #f2ece1;
  --panel: rgba(255, 250, 242, 0.88);
  --panel-strong: #fff8ef;
  --ink: #1f2b2a;
  --muted: #566665;
  --line: rgba(55, 75, 74, 0.16);
  --brand: #a54c2a;
  --brand-dark: #73331b;
  --accent: #2e6f69;
  --shadow: 0 20px 50px rgba(51, 45, 34, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(165, 76, 42, 0.2), transparent 32%),
    radial-gradient(circle at top right, rgba(46, 111, 105, 0.16), transparent 30%),
    linear-gradient(180deg, #f8f1e5 0%, #efe7db 45%, #ebe3d9 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.hero-panel,
.status-strip,
.modal-card,
.book-card,
.empty-state,
.toast {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar,
.hero-panel,
.status-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 60px;
  height: 60px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 12px 24px rgba(46, 111, 105, 0.18);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1.05;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.topbar-actions,
.transport-row,
.modal-actions,
.pagination-inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  margin-top: 22px;
  padding: 28px;
  border-radius: var(--radius-lg);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-text {
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.control-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 248, 239, 0.94);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.search-row,
.toolbar-row,
.chapter-row,
.player-header,
.details-layout {
  display: flex;
  gap: 14px;
}

.toolbar-row {
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  color: var(--muted);
  font-size: 0.92rem;
}

.compact-field {
  min-width: 160px;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(55, 75, 74, 0.18);
  border-radius: 14px;
  background: #fffdf8;
  color: var(--ink);
  padding: 12px 14px;
}

.primary-button,
.ghost-button,
.icon-button {
  border-radius: 999px;
  border: 0;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #cc7048);
  color: #fffaf5;
  padding: 12px 18px;
  box-shadow: 0 12px 28px rgba(165, 76, 42, 0.25);
}

.ghost-button,
.icon-button {
  background: rgba(255, 250, 242, 0.88);
  color: var(--ink);
  border: 1px solid rgba(55, 75, 74, 0.16);
  padding: 11px 16px;
}

.icon-button {
  font-size: 1.8rem;
  line-height: 1;
  width: 46px;
  height: 46px;
  padding: 0;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: center;
  margin: 22px 0;
  padding: 18px 24px;
  border-radius: 24px;
}

.status-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-value {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 600;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.book-card,
.empty-state {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.book-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 28px;
}

.cover-button {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.book-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, rgba(46, 111, 105, 0.18), rgba(165, 76, 42, 0.18));
}

.book-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  flex: 1;
}

.book-title {
  font-size: 1.15rem;
}

.book-subtitle,
.book-description,
.inline-status {
  color: var(--muted);
}

.book-description {
  font-size: 0.95rem;
  line-height: 1.5;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.stat-grid div,
.meta-list div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-grid span,
.meta-list span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.card-actions button {
  flex: 1;
}

.empty-state {
  margin-top: 12px;
  padding: 48px 24px;
  text-align: center;
  border-radius: 30px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 25, 20, 0.42);
}

.modal-card {
  width: min(1120px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: rgba(255, 249, 241, 0.96);
  border-radius: 30px;
  border: 1px solid rgba(55, 75, 74, 0.12);
  box-shadow: 0 28px 60px rgba(30, 25, 20, 0.24);
}

.auth-card {
  width: min(460px, 100%);
}

.modal-header,
.modal-body {
  padding: 22px 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.remember-row {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.details-layout {
  align-items: flex-start;
  padding: 24px;
}

.details-sidebar {
  width: 290px;
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  object-fit: cover;
  background: linear-gradient(135deg, rgba(46, 111, 105, 0.18), rgba(165, 76, 42, 0.18));
}

.meta-list,
.description-panel,
.player-panel {
  padding: 18px;
  border-radius: 22px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.details-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.description-panel {
  line-height: 1.65;
}

.player-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-header {
  justify-content: space-between;
  align-items: center;
}

#audioElement {
  width: 100%;
}

.chapter-field {
  flex: 1;
}

.playback-stats {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  min-width: 160px;
  font-weight: 600;
}

.download-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

progress {
  width: 100%;
  height: 16px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: rgba(46, 111, 105, 0.14);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border-radius: 999px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  min-width: 260px;
  max-width: 420px;
  padding: 14px 18px;
  border-radius: 18px;
  color: #fffaf5;
  background: rgba(31, 43, 42, 0.92);
  box-shadow: 0 20px 40px rgba(30, 25, 20, 0.2);
}

@media (max-width: 1080px) {
  .hero-panel,
  .status-strip,
  .details-layout {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .status-strip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .details-sidebar {
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 720px) {
  .app-shell,
  .modal-backdrop {
    padding: 14px;
  }

  .topbar,
  .hero-panel,
  .status-strip,
  .modal-header,
  .modal-body,
  .details-layout {
    padding: 18px;
  }

  .topbar,
  .search-row,
  .player-header,
  .transport-row,
  .chapter-row,
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions,
  .pagination-inline {
    width: 100%;
    justify-content: space-between;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .playback-stats {
    min-width: auto;
    justify-content: flex-start;
  }
}
