* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #222;
}

header {
  background: #2c6e49;
  color: white;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 { font-size: 1.4rem; margin-bottom: 10px; }

.site-tagline {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.75;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

#dev-banner {
  background: #c0392b;
  color: white;
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

#library-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

#change-library-btn, #toggle-partners-btn {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 0.8rem;
}

#library-picker { margin-bottom: 8px; }

#library-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  font-size: 1rem;
}

#library-suggestions {
  background: white;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
  margin-top: 2px;
}

.suggestion {
  padding: 10px 12px;
  cursor: pointer;
  color: #222;
  border-bottom: 1px solid #eee;
}

.suggestion:hover { background: #f0f0f0; }
.sug-branch { display: block; font-weight: 500; }
.suggestion .sub { display: block; font-size: 0.8rem; color: #666; margin-top: 1px; }

#search-form {
  display: flex;
  gap: 8px;
}

#search-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  font-size: 1rem;
}

#search-form button {
  background: #1b4332;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 1rem;
  cursor: pointer;
}

main { padding: 16px; max-width: 700px; margin: 0 auto; }

#status { color: #555; font-size: 0.9rem; margin-bottom: 12px; min-height: 1.2em; }

.card {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-cover {
  width: 60px;
  min-width: 60px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  background: #ddd;
}

.card-cover-placeholder {
  width: 60px;
  min-width: 60px;
  height: 90px;
  background: #ddd;
  border-radius: 4px;
}

.card-body { flex: 1; min-width: 0; }

.card-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 2px;
}

.card-author { font-size: 0.85rem; color: #555; margin-bottom: 6px; }

.author-link {
  color: #555;
  text-decoration: none;
}

.author-link:hover {
  color: #2c6e49;
  text-decoration: underline;
}

.card-subtitle { font-size: 0.78rem; color: #888; margin-bottom: 3px; line-height: 1.3; }

.card-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-badge--public-domain {
  background: #e8f4fd;
  color: #2471a3;
}

.card-badge--magazine {
  background: #fef3e2;
  color: #b7791f;
}

.card-formats { font-size: 0.75rem; color: #888; margin-bottom: 4px; }

.card-other-creators { font-size: 0.75rem; color: #888; margin-bottom: 2px; }

.card-zero-copies {
  font-size: 0.78rem;
  color: #c0392b;
  margin-top: 4px;
}

.card-libs {
  font-size: 0.82rem;
  color: #2c6e49;
  font-weight: 500;
}

.card-cover-wrap {
  flex-shrink: 0;
}

/* Availability summary */
.avail-now { color: #2c6e49; font-weight: 600; font-size: 0.85rem; }
.avail-wait { color: #888; font-size: 0.85rem; }
.card-avail-summary { margin-top: 6px; }

.card-samples {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.sample-link {
  font-size: 0.78rem;
  color: #666;
  text-decoration: none;
}

.sample-link:hover {
  color: #2c6e49;
  text-decoration: underline;
}

/* Library list (expanded) */
.card-library-list {
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 8px;
}

.lib-entry {
  border-bottom: 1px solid #f0f0f0;
  padding: 6px 0;
}

.lib-entry:last-child { border-bottom: none; }

.lib-entry-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  margin-bottom: 2px;
}

.lib-format-label {
  font-size: 0.78rem;
  color: #555;
  margin-right: 4px;
}

.lib-none-available {
  font-size: 0.82rem;
  color: #888;
  padding: 6px 0;
}

.lib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
  text-decoration: none;
  color: inherit;
  border-radius: 4px;
}

.lib-row:hover { background: #f5faf7; }

.lib-name {
  font-size: 0.85rem;
  color: #333;
}

.lib-wait {
  color: #b7791f;
  font-size: 0.78rem;
}

.lib-action {
  font-size: 0.78rem;
  color: #2c6e49;
  white-space: nowrap;
  flex-shrink: 0;
}

.lib-show-more {
  padding: 6px 0;
  font-size: 0.82rem;
}

.lib-show-more a {
  color: #2c6e49;
  text-decoration: none;
  font-weight: 500;
}

.lib-show-more a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Author mode */
.author-header {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid #2c6e49;
}

.author-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 2px; }
.author-role { font-size: 0.8rem; color: #777; margin-bottom: 2px; }
.author-count { font-size: 0.85rem; color: #555; }
.author-role-group-header { font-size: 0.85rem; color: #555; font-style: italic; margin: 16px 0 6px 0; padding: 0 16px; }
.not-this { margin-top: 8px; font-size: 0.82rem; }

.author-books { margin-bottom: 4px; }

/* Hero card (exact title match) */
.hero-wrap { margin-bottom: 4px; }

.card--hero {
  border: 2px solid #2c6e49;
  box-shadow: 0 2px 8px rgba(44,110,73,0.15);
}

.card--hero .card-title { font-size: 1.1rem; }

/* Other results toggle */
.other-toggle {
  text-align: center;
  padding: 10px;
  font-size: 0.9rem;
}

.other-toggle a, .not-this a, .escape-link {
  color: #2c6e49;
  text-decoration: none;
  font-weight: 500;
}

.other-toggle a:hover, .not-this a:hover { text-decoration: underline; }

.desc-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: #555;
  cursor: pointer;
  margin-top: 4px;
}
.desc-btn:hover { background: #f0f0f0; }

.desc-popup {
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
}
.desc-popup-body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #444;
}
.desc-popup-body p { margin-top: 0.7em; }
.desc-popup-body p:first-child { margin-top: 0; }
.desc-popup-body b, .desc-popup-body strong { color: #222; }
.desc-loading { color: #aaa; font-style: italic; }

/* Format filter pills */
#format-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.format-pill {
  background: white;
  border: 1px solid #ccc;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.format-pill:hover {
  border-color: #2c6e49;
  color: #2c6e49;
}

.format-pill--active {
  background: #2c6e49;
  border-color: #2c6e49;
  color: white;
  font-weight: 500;
}

footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  font-size: 0.85rem;
}

footer a {
  color: #888;
  text-decoration: none;
}

footer a:hover {
  color: #2c6e49;
}
