/* ============================================================
   BenReadin — Design System v2
   ============================================================ */

/* ---- Tokens ---- */
:root {
  --bg:          #eef3f9;
  --surface:     #ffffff;
  --surface-2:   #f3f6fb;
  --border:      #d7dde8;
  --border-soft: #e5eaf2;
  --text:        #1a1f2b;
  --text-muted:  #5a6579;
  --text-subtle: #8c96a6;
  --accent:      #116d63;
  --accent-dark: #0d5a51;
  --accent-glow: rgba(17,109,99,.15);
  --accent-bg:   #e6f4f2;

  --green:       #059669;
  --green-bg:    #d1fae5;
  --amber:       #b45309;
  --amber-bg:    #fef3c7;
  --red:         #dc2626;
  --red-bg:      #fee2e2;
  --gray:        #6b7280;
  --gray-bg:     #f3f4f6;
  --orange:      #ea580c;

  --hero-from:   #1a3340;
  --hero-to:     #0f2530;

  --radius-sm:   6px;
  --radius:      12px;
  --radius-lg:   18px;
  --radius-xl:   24px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow:     0 4px 12px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 12px 30px rgba(0,0,0,.10), 0 4px 10px rgba(0,0,0,.06);
  --shadow-xl:  0 24px 50px rgba(0,0,0,.14), 0 8px 20px rgba(0,0,0,.08);

  --font: "Avenir Next", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --max-width: 1020px;
  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* ---- Dark theme ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #2f3948;
    --surface:     #344152;
    --surface-2:   #2f3b4c;
    --border:      #4a5a72;
    --border-soft: #3d4d62;
    --text:        #e6ebf2;
    --text-muted:  #b4c0d1;
    --text-subtle: #8c96a6;
    --accent:      #3ea894;
    --accent-dark: #2f8a79;
    --accent-glow: rgba(62,168,148,.22);
    --accent-bg:   #1a3530;
    --green-bg:    #052e1c;
    --amber-bg:    #2c1f06;
    --red-bg:      #2c0d0d;
    --gray-bg:     #3a4659;
    --hero-from:   #1a2535;
    --hero-to:     #111c28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:          #2f3948;
  --surface:     #344152;
  --surface-2:   #2f3b4c;
  --border:      #4a5a72;
  --border-soft: #3d4d62;
  --text:        #e6ebf2;
  --text-muted:  #b4c0d1;
  --text-subtle: #8c96a6;
  --accent:      #3ea894;
  --accent-dark: #2f8a79;
  --accent-glow: rgba(62,168,148,.22);
  --accent-bg:   #1a3530;
  --green-bg:    #052e1c;
  --amber-bg:    #2c1f06;
  --red-bg:      #2c0d0d;
  --gray-bg:     #3a4659;
  --hero-from:   #1a2535;
  --hero-to:     #111c28;
  color-scheme: dark;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ================================================================
   HEADER
   ================================================================ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border), var(--shadow-xs);
  backdrop-filter: blur(8px);
}
.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.site-logo:hover { text-decoration: none; }
.site-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .85rem;
  font-weight: 900;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.site-logo a { color: inherit; }
.site-logo a:hover { text-decoration: none; }

/* ================================================================
   HERO  (index page)
   ================================================================ */
.hero {
  background: linear-gradient(160deg, var(--hero-from) 0%, var(--hero-to) 100%);
  padding: 80px 24px 96px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 80%, rgba(62,168,148,.18) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 20%, rgba(17,109,99,.14) 0%, transparent 60%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }
.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -.6px;
  line-height: 1.12;
  color: #fff;
  margin-bottom: 16px;
}
.hero h1 span {
  background: linear-gradient(90deg, #3ea894, #7dd3c8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero > .container > p {
  font-size: 1.1rem;
  color: rgba(255,255,255,.7);
  max-width: 500px;
  margin: 0 auto 40px;
  font-weight: 400;
  line-height: 1.6;
}

/* ================================================================
   SEARCH CARD
   ================================================================ */
.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  max-width: 620px;
  margin: 0 auto;
  box-shadow: var(--shadow-xl);
  text-align: left;
}
.form-group { margin-bottom: 24px; }
.form-group:last-of-type { margin-bottom: 0; }

label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}
.url-example {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.url-example-label {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}
.url-example-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  color: rgba(255,255,255,.75);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.url-example-btn:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}
.url-example-btn svg {
  flex-shrink: 0;
  opacity: .7;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
input[type="text"]:focus,
input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--surface);
}
input::placeholder { color: var(--text-subtle); }

/* Library chips */
.library-input-wrap { position: relative; }
.library-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: text;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  align-items: center;
}
.library-chips.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--surface);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-bg);
  color: var(--accent-dark);
  border: 1px solid rgba(17,109,99,.18);
  border-radius: 100px;
  padding: 3px 12px 3px 12px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-remove, .chip-edit {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  padding: 0;
  line-height: 1;
  opacity: .6;
  display: flex;
  align-items: center;
  transition: opacity var(--transition);
}
.chip-remove { font-size: 1rem; }
.chip-edit   { font-size: .85rem; }
.chip-remove:hover, .chip-edit:hover { opacity: 1; }

.chip-input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: .9375rem;
  color: var(--text);
  min-width: 140px;
  flex: 1;
  padding: 3px 0;
}
.chip-input::placeholder { color: var(--text-subtle); }

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background var(--transition);
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--accent-bg); }
.autocomplete-item .lib-name { font-weight: 500; color: var(--text); }
.autocomplete-item .lib-key { font-size: .78rem; color: var(--text-muted); font-family: var(--font-mono); }
.autocomplete-header {
  padding: 6px 12px 4px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-subtle);
  pointer-events: none;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  margin-top: 28px;
  width: 100%;
  box-shadow: 0 4px 16px var(--accent-glow), 0 1px 3px rgba(0,0,0,.12);
  letter-spacing: .01em;
}
.btn-primary:hover {
  opacity: .9;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow), 0 2px 6px rgba(0,0,0,.12);
}
.btn-primary:active { transform: none; opacity: 1; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--surface-2);
  text-decoration: none;
}

.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}
.btn-theme:hover { border-color: var(--accent); background: var(--accent-bg); }

.btn-copy-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent-bg);
  color: var(--accent);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 600;
  border: 1.5px solid rgba(17,109,99,.22);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-copy-link:hover { background: var(--accent); color: #fff; }

.btn-kindle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #ff9900;
  color: #111;
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-kindle:hover { background: #e88a00; text-decoration: none; color: #111; transform: translateY(-1px); }

.btn-borrow {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-borrow:hover { opacity: .88; text-decoration: none; color: #fff; transform: translateY(-1px); }

.btn-gutenberg-sm {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: #d1fae5;
  color: #065f46;
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  border: 1.5px solid #6ee7b7;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.btn-gutenberg-sm:hover { background: #a7f3d0; text-decoration: none; }

[data-theme="dark"] .btn-gutenberg-sm {
  background: #052e1c;
  color: #6ee7b7;
  border-color: #065f46;
}
[data-theme="dark"] .btn-gutenberg-sm:hover { background: #064e32; }

.btn-sm { padding: 5px 11px; font-size: .775rem; }

/* Card action groups */
.card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.card-actions-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar-wrap {
  background: var(--border-soft);
  border-radius: 100px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  border-radius: 100px;
  transition: width .35s ease;
  width: 0%;
}
.progress-label {
  font-size: .8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ================================================================
   RESULTS PAGE STATUS
   ================================================================ */
.results-status {
  padding: 24px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.results-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.3px;
}
.results-count {
  font-size: .875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ================================================================
   BOOK GRID + CARDS
   ================================================================ */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  padding-bottom: 60px;
}

.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  opacity: 0;
  animation: fadeUp .28s ease forwards;
}
.book-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--border-soft);
}
.book-card.hidden { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.book-cover { flex-shrink: 0; width: 76px; }
.book-cover img {
  width: 76px;
  height: 114px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.12);
  background: var(--border-soft);
}
.book-cover-placeholder {
  width: 76px;
  height: 114px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--border-soft), var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  font-size: 1.6rem;
}

.book-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.book-title {
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -.01em;
}
.book-author {
  font-size: .8125rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}
.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -4px;
}
.book-pages {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-subtle);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 100px;
  padding: 1px 8px;
  white-space: nowrap;
}

/* Ratings */
.book-rating-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rating-avg {
  font-size: .75rem;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 100px;
  padding: 2px 8px;
  white-space: nowrap;
}
[data-theme="dark"] .rating-avg {
  background: #2c1f06;
  border-color: #78350f;
  color: #fbbf24;
}
.rating-user {
  font-size: .8rem;
  color: #d97706;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Description details */
.book-description-details { margin-top: 2px; }
.book-description-details summary {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-subtle);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color var(--transition);
}
.book-description-details summary::-webkit-details-marker { display: none; }
.book-description-details summary::before {
  content: '▶';
  font-size: .55rem;
  transition: transform var(--transition);
  display: inline-block;
}
.book-description-details[open] summary::before { transform: rotate(90deg); }
.book-description-details summary:hover { color: var(--text-muted); }
.book-description {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 8px;
  font-style: italic;
}

/* ================================================================
   LIBRARY ROWS + AVAILABILITY BADGES
   ================================================================ */
.library-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.library-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
}
.lib-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 60px;
  flex-shrink: 0;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: color var(--transition), border-color var(--transition);
}
.lib-label:hover { color: var(--accent); border-bottom-color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .01em;
}
.badge-available { background: var(--green-bg);  color: var(--green); }
.badge-wait      { background: var(--amber-bg);  color: var(--amber); }
.badge-unavail   { background: var(--red-bg);    color: var(--red); }
.badge-notfound  { background: var(--gray-bg);   color: var(--gray); }

/* Kindle delivery indicator inside badge */
.badge-kindle-pill {
  display: inline-flex;
  align-items: center;
  font-size: .66rem;
  font-weight: 800;
  background: #ff9900;
  color: #111;
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0;
}

/* ================================================================
   PRICE PILLS
   ================================================================ */
.price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.price-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
}
.price-pill .pill-label { font-weight: 500; font-size: .7rem; }
.price-pill .pill-amount { color: var(--text); font-weight: 700; }
.price-pill-free {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}
[data-theme="dark"] .price-pill-free { background: #052e1c; color: #6ee7b7; border-color: #065f46; }

/* ================================================================
   FILTER / SORT BAR
   ================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 0 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 24px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.filter-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 5px 13px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filter-chip-kindle { border-color: #fbbf24; color: #92400e; }
.filter-chip-kindle:hover { border-color: #d97706; color: #92400e; background: #fef3c7; }
.filter-chip-kindle.active { background: #d97706; border-color: #d97706; color: #fff; }

[data-theme="dark"] .filter-chip-kindle { border-color: #78350f; color: #fbbf24; }
[data-theme="dark"] .filter-chip-kindle:hover { background: #2c1f06; }
[data-theme="dark"] .filter-chip-kindle.active { background: #b45309; border-color: #b45309; color: #fff; }

.filter-chip-gutenberg { border-color: #6ee7b7; color: #059669; }
.filter-chip-gutenberg:hover { border-color: #059669; color: #059669; background: #d1fae5; }
.filter-chip-gutenberg.active { background: #059669; border-color: #059669; color: #fff; }

[data-theme="dark"] .filter-chip-gutenberg { border-color: #065f46; color: #6ee7b7; }
[data-theme="dark"] .filter-chip-gutenberg:hover { background: #052e1c; }
[data-theme="dark"] .filter-chip-gutenberg.active { background: #059669; color: #fff; }

.filter-select {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ================================================================
   LEGEND
   ================================================================ */
.results-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: .75rem;
  color: var(--text-muted);
}
.results-legend strong {
  font-weight: 700;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .06em;
  margin-right: 4px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* ================================================================
   RENAME MODAL
   ================================================================ */
.rename-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}
.rename-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: min(380px, 92vw);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rename-modal-title { font-weight: 800; font-size: 1rem; color: var(--text); }
.rename-modal-input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: .9375rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.rename-modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.rename-modal-hint { font-size: .72rem; color: var(--text-subtle); font-family: var(--font-mono); }
.rename-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ================================================================
   RECOMMENDATIONS BUTTON
   ================================================================ */
.btn-recs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent-bg);
  color: var(--accent);
  font-family: var(--font);
  font-size: .8125rem;
  font-weight: 700;
  border: 1.5px solid rgba(17,109,99,.28);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-recs:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-recs:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.recs-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: .875rem;
  padding: 12px 0;
}
.recs-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   RECOMMENDATIONS
   ================================================================ */
.recs-panel {
  margin-top: 56px;
  padding-top: 36px;
  border-top: 2px solid var(--border);
}
.recs-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}
.recs-title { font-size: 1.1rem; font-weight: 800; color: var(--text); flex: 1 1 auto; letter-spacing: -.2px; }
.recs-subtitle { font-size: .8rem; color: var(--text-muted); flex-basis: 100%; margin-top: -6px; }
.recs-toggle {
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.recs-toggle:hover { border-color: var(--accent); color: var(--accent); }

.recs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.rec-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 14px;
  display: flex;
  gap: 12px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.rec-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.rec-cover { flex-shrink: 0; width: 54px; }
.rec-cover img {
  width: 54px; height: 81px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  background: var(--border-soft);
}
.rec-cover-placeholder {
  width: 54px; height: 81px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--border-soft), var(--border));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle); font-size: 1.2rem;
}
.rec-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rec-title {
  font-size: .85rem; font-weight: 700; line-height: 1.3; color: var(--text);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.rec-author  { font-size: .75rem; color: var(--text-muted); }
.rec-because { font-size: .72rem; color: var(--text-subtle); font-style: italic; }
.rec-badges  { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ================================================================
   ERROR BANNER
   ================================================================ */
.error-banner {
  background: var(--red-bg);
  border: 1px solid rgba(220,38,38,.3);
  color: var(--red);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: none;
}
.error-banner.visible { display: block; }

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
  color: var(--text-subtle);
  font-size: .8rem;
  background: var(--surface);
}

/* ================================================================
   SKELETON
   ================================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 50%, var(--border-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 700px) {
  .hero { padding: 56px 20px 72px; }
  .hero h1 { font-size: 2.1rem; }
  .search-card { padding: 24px 20px; border-radius: var(--radius-lg); }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { padding: 16px; }
  .book-cover { width: 64px; }
  .book-cover img { width: 64px; height: 96px; }
  .book-cover-placeholder { width: 64px; height: 96px; }
  .recs-grid { grid-template-columns: 1fr; }
  .filter-bar { gap: 10px; }
}
