:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(148, 163, 184, 0.2);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --ok: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.32), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.24), transparent 34rem),
    var(--bg);
}

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

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.app-version {
  padding: 2px 7px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 999px;
  color: rgba(226, 232, 240, 0.88);
  background: rgba(14, 165, 233, 0.12);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: none;
}

.app-version[hidden] {
  display: none;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.hero p:last-child {
  max-width: 1000px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.panel {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.38);
  backdrop-filter: blur(18px);
}

[hidden] {
  display: none !important;
}

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

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 18px var(--ok);
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.list-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
}

.list-filter-back,
.detail-filter-link {
  cursor: pointer;
}

.list-filter-back {
  padding: 9px 13px;
  color: white;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.list-filter-back:not(:disabled):hover,
.list-filter-back:not(:disabled):focus-visible {
  border-color: rgba(125, 211, 252, 0.82);
  background: linear-gradient(135deg, #7dd3fc, #2563eb);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
  transform: translateY(-1px);
  outline: none;
}

#list-filter-label {
  font-weight: 700;
}

input,
button {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  font: inherit;
}

input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(15, 23, 42, 0.7);
}

input:focus {
  border-color: rgba(56, 189, 248, 0.74);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
  outline: none;
}

button {
  padding: 12px 18px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

input:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.status-text {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.pagination button {
  padding: 9px 13px;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.pagination button:not(:disabled):hover,
.pagination button:not(:disabled):focus-visible {
  border-color: rgba(125, 211, 252, 0.82);
  background: linear-gradient(135deg, #7dd3fc, #2563eb);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
  transform: translateY(-1px);
  outline: none;
}

.pagination-bottom {
  margin: 16px 0 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

.book-row {
  cursor: pointer;
}

.book-row:hover,
.book-row:focus-visible {
  background: rgba(15, 23, 42, 0.36);
  outline: none;
}

.book-row:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.42);
}

.cover-cell {
  width: 72px;
}

.cover-thumb,
.cover-placeholder {
  display: block;
  width: 48px;
  height: 64px;
  border-radius: 8px;
}

.cover-thumb {
  object-fit: cover;
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 8px 22px rgba(2, 6, 23, 0.35);
}

.cover-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.48);
}

.empty-cell {
  color: var(--muted);
}

.mobile-meta-cell {
  display: none;
}

.mobile-narrators-cell {
  display: none;
}

.tags-cell {
  min-width: 140px;
}

.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.tag-badge-0 { background: #0ea5e9; }
.tag-badge-1 { background: #7c3aed; }
.tag-badge-2 { background: #db2777; }
.tag-badge-3 { background: #16a34a; }
.tag-badge-4 { background: #ea580c; }
.tag-badge-5 { background: #475569; }

.details-panel {
  padding: 18px;
}

.detail-back {
  margin-bottom: 16px;
  padding: 9px 13px;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.detail-back:not(:disabled):hover,
.detail-back:not(:disabled):focus-visible {
  border-color: rgba(125, 211, 252, 0.82);
  background: linear-gradient(135deg, #7dd3fc, #2563eb);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
  transform: translateY(-1px);
  outline: none;
}

.detail-card {
  display: grid;
  gap: 24px;
  max-width: 980px;
  margin: 0 auto;
}

.detail-top {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.detail-cover,
.detail-cover-placeholder {
  display: block;
  width: 240px;
  height: 240px;
  border-radius: 16px;
}

.detail-cover {
  object-fit: cover;
  background: rgba(15, 23, 42, 0.8);
  box-shadow: 0 18px 46px rgba(2, 6, 23, 0.46);
}

.detail-cover-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.48);
}

.detail-summary h2 {
  margin: 0 0 18px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
}

.detail-facts {
  display: grid;
  gap: 12px;
  margin: 0;
}

.detail-fact {
  display: grid;
  gap: 5px;
}

.detail-fact dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-fact dd {
  margin: 0;
  color: var(--text);
}

.detail-filter-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--accent);
  background: none;
  font: inherit;
  text-align: left;
}

.detail-filter-link:hover,
.detail-filter-link:focus-visible {
  color: #7dd3fc;
  text-decoration: underline;
  outline: none;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.detail-section h3 {
  margin: 0;
  font-size: 1.28rem;
}

.detail-description {
  max-width: 900px;
  margin: 0;
  color: rgba(226, 232, 240, 0.9);
  font-size: 1.02rem;
  line-height: 1.75;
  white-space: pre-line;
}

.detail-chapters {
  display: grid;
  gap: 0;
  max-width: 900px;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.36);
}

.detail-chapters li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.detail-chapters li:last-child {
  border-bottom: 0;
}

.detail-chapter-title {
  min-width: 0;
}

.detail-chapter-duration {
  color: var(--muted);
  white-space: nowrap;
}

.detail-back-bottom {
  margin: 18px 0 0;
}

.meta-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 9px;
  align-items: center;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.meta-item:not(:last-child)::after {
  content: "·";
  margin-left: 9px;
  color: rgba(148, 163, 184, 0.68);
}

.meta-icon {
  line-height: 1;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding: 28px 0;
  }

  .panel {
    border-radius: 20px;
    padding: 14px;
  }

  .toolbar {
    flex-direction: column;
  }

  .pagination {
    justify-content: space-between;
  }

  .pagination button {
    min-width: 112px;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  .book-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-areas:
      "cover title"
      "cover author"
      "cover series"
      "cover tags"
      "cover narrators"
      "cover meta";
    gap: 6px 14px;
    padding: 18px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  }

  td {
    padding: 0;
    border: 0;
  }

  .cover-cell {
    grid-area: cover;
    align-self: start;
    width: auto;
  }

  .cover-thumb,
  .cover-placeholder {
    width: 72px;
    height: 96px;
    border-radius: 10px;
  }

  .title-cell {
    grid-area: title;
    align-self: end;
    font-size: 1.06rem;
    font-weight: 800;
    line-height: 1.25;
  }

  .author-cell {
    grid-area: author;
    color: var(--text);
    font-weight: 600;
  }

  .series-cell {
    grid-area: series;
    color: var(--muted);
    font-size: 0.92rem;
  }

  .series-cell {
    font-size: 0;
  }

  .series-cell.is-empty {
    display: none;
  }

  .series-cell::after {
    content: attr(data-mobile-label);
    font-size: 0.92rem;
  }

  .volume-cell {
    display: none;
  }

  .tags-cell {
    grid-area: tags;
    min-width: 0;
  }

  .mobile-narrators-cell {
    display: flex;
    grid-area: narrators;
    gap: 6px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .mobile-narrators-cell:empty {
    display: none;
  }

  .mobile-narrators-label {
    flex: 0 0 auto;
    color: rgba(226, 232, 240, 0.88);
    font-weight: 700;
  }

  .tag-badges {
    min-width: 0;
  }

  .duration-cell,
  .size-cell,
  .date-cell {
    display: none;
  }

  .mobile-meta-cell {
    display: flex;
    grid-area: meta;
    flex-wrap: wrap;
    gap: 0 8px;
    color: var(--muted);
    font-size: 0.88rem;
  }

  .mobile-meta-cell span:not(:last-child)::after {
    content: "·";
    margin-left: 8px;
    color: rgba(148, 163, 184, 0.68);
  }

  .details-panel {
    padding: 14px;
  }

  .detail-back {
    width: auto;
    margin-bottom: 14px;
  }

  .detail-card {
    gap: 22px;
    max-width: none;
  }

  .detail-top {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .detail-cover-wrap {
    display: grid;
    place-items: center;
    padding: 8px 0 4px;
  }

  .detail-cover,
  .detail-cover-placeholder {
    width: 180px;
    height: 180px;
    border-radius: 14px;
  }

  .detail-summary h2 {
    margin-bottom: 16px;
    font-size: clamp(2rem, 11vw, 3.1rem);
  }

  .detail-facts {
    gap: 13px;
  }

  .detail-description {
    font-size: 1rem;
    line-height: 1.7;
  }

  .detail-chapters {
    border-radius: 12px;
  }

  .detail-chapters li {
    gap: 12px;
    padding: 11px 12px;
  }

  td::before {
    display: none;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}
