/* ============================================================
   BooksYard — App stylesheet
   Design language: teal primary, white cards, rounded, bottom nav
   ============================================================ */

:root {
  --primary: #12BFA4;
  --primary-dark: #0E9A84;
  --primary-soft: #E6F8F4;
  --accent: #6B3FA0;
  --accent-soft: #F1EAF9;

  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;

  --text: #1A1D21;
  --text-2: #5A6470;
  --text-3: #8D96A3;

  --line: #E7EAEE;
  --line-2: #F0F2F5;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  --nav-h: 60px;
  --appbar-h: 58px;

  --font: "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans Devanagari", "Nirmala UI", Arial, sans-serif;
}

/* Dark theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1319;
  --surface: #151C24;
  --surface-2: #1B2430;

  --text: #E6ECF3;
  --text-2: #A6B2C2;
  --text-3: #76849A;

  --line: #26313D;
  --line-2: #1E2833;

  --primary-soft: #103029;
  --accent-soft: #251A38;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow: 0 6px 18px rgba(0, 0, 0, .55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .65);
}

/* The [hidden] attribute must win over display:flex — keep these rules first
   so the drawer / backdrop never show unless explicitly opened. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   APP BAR
   ============================================================ */
.appbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.appbar-inner {
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  max-width: 1100px;
  margin: 0 auto;
}

.appbar-title {
  flex: 1;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: var(--line-2); }
.icon-btn:active { transform: scale(.94); }

/* Theme toggle: show a moon in light mode and a sun in dark mode */
.theme-toggle .theme-icon { display: none; }
.theme-toggle .theme-icon.moon { display: block; }
html[data-theme="dark"] .theme-toggle .theme-icon.moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon.sun { display: block; }

/* Search slide-down */
.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-height: 0;
  overflow: hidden;
  padding: 0 16px;
  transition: max-height .25s ease, padding .25s ease;
  background: var(--surface);
}
.searchbar.open { max-height: 62px; padding: 10px 16px; }
.searchbar svg { color: var(--text-3); flex: 0 0 auto; }
.searchbar input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.searchbar input:focus { border-color: var(--primary); background: var(--surface); }
.clear-search { color: var(--text-3); font-size: 16px; padding: 4px; }

/* ============================================================
   DRAWER
   ============================================================ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 15, 20, .45);
  z-index: 90;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 282px;
  max-width: 84vw;
  background: var(--surface);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideIn .25s cubic-bezier(.2,.8,.3,1);
  overflow-y: auto;
}
@keyframes slideIn { from { transform: translateX(-100%) } to { transform: none } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 18px 14px 16px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}
.drawer-logo { display: flex; align-items: center; gap: 11px; min-width: 0; }
.drawer-logo-mark {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2);
  border-radius: 11px;
  font-weight: 800; font-size: 15px;
  letter-spacing: .5px;
}
.drawer-logo strong { display: block; font-size: 16px; }
.drawer-logo small { display: block; opacity: .85; font-size: 12px; }
.drawer-head .icon-btn { color: #fff; }
.drawer-head .icon-btn:hover { background: rgba(255,255,255,.15); }

.drawer-nav { padding: 10px 0; flex: 1; }
.drawer-nav a {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  font-size: 15px; font-weight: 500;
  color: var(--text-2);
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.drawer-nav a svg { color: var(--text-3); transition: color .15s; }
.drawer-nav a:hover { background: var(--surface-2); color: var(--text); }
.drawer-nav a.is-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 600;
}
.drawer-nav a.is-active svg { color: var(--primary); }

.drawer-foot {
  padding: 14px 20px 20px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--text-3);
}
.drawer-foot p { margin: 0 0 6px; }
.drawer-admin { color: var(--primary); font-weight: 600; }

/* ============================================================
   PAGE + SECTIONS
   ============================================================ */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 12px 28px;
}

.section { margin-bottom: 26px; }
.section:last-child { margin-bottom: 8px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.section-head h2 .count { color: var(--text-3); font-weight: 500; font-size: 14px; margin-left: 6px; }
.section-head a { font-size: 13.5px; color: var(--primary); font-weight: 600; white-space: nowrap; }
.section-head a:hover { text-decoration: underline; }

/* Filter chips */
.chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 4px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 15px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ============================================================
   BOOK GRID
   ============================================================ */
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 12px;
}

.book-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.book-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #e8ecf0, #dde3ea);
  overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }

.cover-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .4px;
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.cover-badge.audio { background: var(--accent); }

.book-meta { padding: 10px 11px 12px; flex: 1; display: flex; flex-direction: column; }
.book-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.32;
  margin: 0 0 5px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  font-size: 12.5px;
  color: var(--text-2);
  margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.book-sub {
  font-size: 11.5px; color: var(--text-3); margin: 4px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.book-card .card-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mini-badge {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px;
  background: var(--primary-soft); color: var(--primary-dark);
}
.mini-badge.purple { background: var(--accent-soft); color: var(--accent); }
.mini-badge.grey { background: var(--line-2); color: var(--text-2); }

/* ============================================================
   CATEGORY GRID (image tiles)
   ============================================================ */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.cat-tile {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-end;
  isolation: isolate;
}
.cat-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.cat-tile::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.30) 45%, rgba(0,0,0,.08) 100%);
}
.cat-tile h3 {
  margin: 0;
  padding: 14px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.2px;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.cat-tile .cat-count {
  position: absolute; top: 10px; right: 12px;
  background: rgba(255,255,255,.22);
  color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.cat-tile.fallback { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }

/* ============================================================
   AUTHOR GRID
   ============================================================ */
.author-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.author-tile {
  position: relative;
  aspect-ratio: 16 / 11;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-end;
  isolation: isolate;
}
.author-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.author-tile::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.32) 45%, rgba(0,0,0,.05) 100%);
}
.author-tile h3 {
  margin: 0; padding: 12px 14px;
  color: #fff; font-size: 16.5px; font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.author-tile .book-count {
  position: absolute; top: 10px; right: 12px;
  background: rgba(255,255,255,.22); color: #fff;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.author-tile.fallback { background: linear-gradient(135deg, #6B7280, #4B5563); }
.author-tile.fallback .avatar-initial {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; font-weight: 800; color: rgba(255,255,255,.28);
}

/* ============================================================
   BOOK DETAIL
   ============================================================ */
.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex; gap: 18px;
  align-items: flex-start;
}
.detail-cover {
  width: 128px; flex: 0 0 auto;
  aspect-ratio: 3/4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
}
/* contain, not cover — the whole artwork stays visible instead of being cropped */
.detail-cover img { width: 100%; height: 100%; object-fit: contain; }
.detail-info { flex: 1; min-width: 0; }
.detail-info h1 {
  margin: 0 0 6px;
  font-size: 22px; font-weight: 700; line-height: 1.24; letter-spacing: -.3px;
}
.detail-author { color: var(--text-2); font-size: 15px; margin: 0 0 10px; }
.detail-author a { color: var(--primary-dark); font-weight: 600; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.detail-tags .mini-badge { font-size: 11.5px; padding: 3px 9px; }

.detail-actions { display: flex; flex-direction: row; align-items: stretch; gap: 10px; }
.detail-actions .btn { width: auto; padding-left: 16px; padding-right: 16px; }
.detail-actions .btn:not(.btn-bookmark) { flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.detail-actions .btn-bookmark { flex: 0 0 auto; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 14.5px; font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s, transform .12s, box-shadow .15s;
  text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 19px; height: 19px; }
.btn-outline { background: transparent; color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-dark { background: #1F2937; }
.btn-dark:hover { background: #111827; }
.btn-purple { background: var(--accent); }
.btn-purple:hover { background: #57338a; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ============================================================
   AUDIO TRACK ROWS
   ============================================================ */
.track-row {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .15s;
}
.track-row:hover { background: var(--surface-2); transform: translateX(2px); }
.track-no {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12.5px; font-weight: 700;
}
.track-title {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-dur { flex: 0 0 auto; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  box-shadow: 0 -2px 10px rgba(16,24,40,.05);
}
.bottomnav a {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  transition: color .15s;
  min-width: 0;
}
.bottomnav a svg { width: 21px; height: 21px; }
.bottomnav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottomnav a.is-active { color: var(--primary); font-weight: 600; }

/* ============================================================
   EMPTY / PAGINATION / MISC
   ============================================================ */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-3);
}
.empty svg { width: 54px; height: 54px; margin: 0 auto 14px; color: var(--line); }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--text-2); font-weight: 600; }
.empty p { margin: 0; font-size: 14px; }

.pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 8px; margin: 26px 0 8px;
}
.pagination a, .pagination span {
  min-width: 38px; height: 38px;
  display: grid; place-items: center;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600;
  color: var(--text-2);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: .4; pointer-events: none; }

.badge-new {
  background: var(--primary);
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: .3px;
}

.page-head {
  margin: 4px 4px 16px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 21px; font-weight: 700; letter-spacing: -.3px;
}
.page-head p { margin: 0; color: var(--text-2); font-size: 14px; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--nav-h) + 18px);
  transform: translateX(-50%) translateY(20px);
  background: #1F2937;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bookmark-btn {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(255,255,255,.9);
  color: var(--text-3);
  box-shadow: var(--shadow-sm);
  transition: color .15s, transform .15s;
  z-index: 2;
}
.bookmark-btn:hover { transform: scale(1.08); }
.bookmark-btn.is-saved { color: var(--primary); }
.bookmark-btn.is-saved svg { fill: var(--primary); }

/* Saved bookmark on the book detail page */
.btn-bookmark.is-saved {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-bookmark.is-saved:hover { background: var(--primary-dark); }
.btn-bookmark.is-saved svg { fill: currentColor; }

/* ============================================================
   PERSISTENT MINI PLAYER
   Sits above the bottom nav and survives in-app navigation.
   ============================================================ */
.mini-player {
  position: fixed;
  left: 8px; right: 8px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 6px);
  height: 58px;
  z-index: 68;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px 7px;
  background: #1B2128;
  color: #EDEFF2;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  animation: miniIn .22s ease;
  overflow: hidden;
}
@keyframes miniIn { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }

.mp-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0; border: 0; background: transparent;
  color: inherit; text-align: left; cursor: pointer;
  font: inherit;
}
.mp-cover {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 8px; object-fit: cover; background: #2A323B;
}
.mp-text { flex: 1; min-width: 0; }
.mp-title {
  display: block; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-sub {
  display: block; font-size: 11px; color: #9AA3AE;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.mp-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; background: transparent; color: #EDEFF2;
  border-radius: 50%; cursor: pointer;
}
.mp-btn:hover { background: rgba(255,255,255,.1); }
.mp-btn svg { width: 20px; height: 20px; }
.mp-toggle svg { fill: currentColor; stroke: none; }
.mp-toggle svg.pause-icon { fill: none; stroke: currentColor; stroke-width: 3; }
.mp-close svg { width: 16px; height: 16px; color: #9AA3AE; }
.mp-progress {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: rgba(255,255,255,.12);
}
.mp-progress span { display: block; height: 100%; width: 0; background: var(--primary); }

body.has-mini { padding-bottom: calc(var(--nav-h) + 74px + env(safe-area-inset-bottom)); }
body.has-mini .toast { bottom: calc(var(--nav-h) + 86px); }

/* Full-screen player overlay — reuses the .player-body / .p-* styles
   from player.css, so only positioning lives here. */
.by-overlay {
  position: fixed;
  inset: 0;
  z-index: 160;
}
body.by-locked { overflow: hidden; }

/* ============================================================
   DARK THEME OVERRIDES
   ============================================================ */
html[data-theme="dark"] .book-cover {
  background: linear-gradient(135deg, #1B2430, #141B24);
}
html[data-theme="dark"] .bookmark-btn {
  background: rgba(21, 28, 36, .88);
  color: var(--text-3);
}
html[data-theme="dark"] .bookmark-btn:hover { color: var(--text); }
html[data-theme="dark"] .toast {
  background: #E6ECF3;
  color: #131A22;
}
html[data-theme="dark"] .section-head a,
html[data-theme="dark"] .detail-author a,
html[data-theme="dark"] .drawer-admin,
html[data-theme="dark"] .btn-outline {
  color: #33D6B8;
}
html[data-theme="dark"] .btn-outline { border-color: #24B79C; }
html[data-theme="dark"] .btn-bookmark.is-saved { background: var(--primary); border-color: var(--primary); color: #fff; }
html[data-theme="dark"] .btn-bookmark.is-saved:hover { background: var(--primary-dark); }
html[data-theme="dark"] .btn-bookmark.is-saved svg { fill: currentColor; }
html[data-theme="dark"] .mini-badge { color: #33D6B8; }
html[data-theme="dark"] .mini-badge.purple { color: #C4A6F5; }
html[data-theme="dark"] .mini-badge.grey { color: var(--text-2); }
html[data-theme="dark"] .empty svg { color: #2B3644; }
html[data-theme="dark"] .searchbar.open { box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .pagination a,
html[data-theme="dark"] .pagination span { background: var(--surface); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 560px) {
  .book-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .author-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .page { padding: 22px 20px 40px; }
  .book-grid { grid-template-columns: repeat(6, 1fr); }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .author-grid { grid-template-columns: repeat(4, 1fr); }
  .detail-cover { width: 168px; }
  .detail-info h1 { font-size: 27px; }
  .detail-card { padding: 24px; gap: 24px; }
}

/* Mobile-first detail card: stack vertically on small screens */
@media (max-width: 480px) {
  .detail-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 14px;
  }
  .detail-cover {
    width: 140px;
    margin: 0 auto;
  }
  .detail-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .detail-info h1 {
    font-size: 20px;
    text-align: center;
  }
  .detail-author {
    text-align: center;
  }
  .detail-tags {
    justify-content: center;
  }
  .detail-actions {
    width: 100%;
    max-width: 320px;
  }
  .detail-actions .btn-bookmark [data-bm-label] { display: none; }
  .detail-actions .btn-bookmark { padding: 12px 13px; }
  .detail-actions .btn:not(.btn-bookmark) {
    font-size: 13.5px;
    letter-spacing: .3px;
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (max-width: 380px) {
  .book-grid { gap: 11px 9px; }
  .book-meta { padding: 8px 9px 10px; }
  .book-title { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
