:root {
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #f3e8ff;
  --primary-glow: rgba(124, 58, 237, 0.12);
  --bg: #f7f5fb;
  --bg-mesh: radial-gradient(ellipse 120% 80% at 10% -20%, rgba(167, 139, 250, 0.18), transparent 50%),
    radial-gradient(ellipse 80% 60% at 90% 0%, rgba(196, 181, 253, 0.14), transparent 45%),
    var(--bg);
  --card: #ffffff;
  --text: #1e1b4b;
  --text-muted: #64748b;
  --border: #e9e5f5;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 20px rgba(30, 27, 75, 0.06);
  --shadow-hover: 0 20px 40px rgba(124, 58, 237, 0.18);
  --sidebar-w: 260px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body.bs-body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-mesh);
  background-attachment: fixed;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.bs-brand span,
.bs-logo-lg span span,
.bs-sidebar-brand span { color: var(--primary); }

.bs-logo-icon { font-size: 1.25rem; }

/* Header */
.bs-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.bs-header .navbar-brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
}

.bs-header .nav-link {
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition);
}

.bs-header .nav-link:hover { color: var(--primary); }

.bs-search-form { max-width: 320px; gap: 0.5rem; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.bs-main { flex: 1; }

/* Hero */
.bs-hero {
  background: linear-gradient(135deg, rgba(243, 232, 255, 0.9) 0%, rgba(255, 255, 255, 0.95) 45%, transparent 100%);
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
}

.bs-hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.bs-hero-text {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 540px;
  margin-bottom: 1.5rem;
}

.bs-hero-search {
  display: flex;
  gap: 0.75rem;
  max-width: 520px;
}

.bs-hero-art {
  font-size: 8rem;
  filter: drop-shadow(0 20px 40px rgba(139, 92, 246, 0.2));
}

/* Sections */
.bs-section { padding: 3rem 0; }
.bs-section-muted {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
}

.bs-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.bs-section-head h2 { font-weight: 700; margin: 0; }

.bs-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.bs-link:hover { color: var(--primary-hover); }

/* Book grid */
.bs-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}

.bs-book-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow);
}

.bs-book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(124, 58, 237, 0.25);
}

.bs-book-cover {
  display: block;
  aspect-ratio: 2/3;
  background: linear-gradient(145deg, var(--primary-soft), #e9e5f5);
  overflow: hidden;
  position: relative;
}

.bs-book-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(30, 27, 75, 0.35) 0%, transparent 45%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.bs-book-card:hover .bs-book-cover::after {
  opacity: 1;
}

.bs-book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.bs-book-card:hover .bs-book-cover img { transform: scale(1.04); }

.bs-book-body { padding: 1rem; }

.bs-book-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

.bs-book-title a {
  color: var(--text);
  text-decoration: none;
}
.bs-book-title a:hover { color: var(--primary); }

.bs-book-author {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.bs-book-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bs-rating {
  color: #f59e0b;
  font-weight: 600;
  font-size: 0.875rem;
}

.bs-book-actions { margin-top: 0.75rem; }

.btn-favorite {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-favorite:hover,
.btn-favorite.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Genre cards */
.bs-genre-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  color: var(--text);
  transition: all var(--transition);
}

.bs-genre-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-hover);
}

/* Review cards */
.bs-review-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: 100%;
}

/* Filter */
.bs-filter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: sticky;
  top: 1rem;
}

/* Book detail */
.bs-back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}
.bs-back-link:hover { color: var(--primary); }

.bs-book-author-lg {
  font-size: 1.125rem;
  color: var(--text-muted);
}

.bs-book-desc {
  line-height: 1.7;
  margin-top: 1rem;
}

.bs-book-cover-lg {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-hover);
  background: linear-gradient(145deg, var(--primary-soft), #e9e5f5);
  aspect-ratio: 2/3;
  max-width: 320px;
  margin-left: auto;
}

.bs-book-cover-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bs-reviews-section {
  background: var(--primary-soft);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.bs-rating-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.bs-rating-bar-row {
  display: grid;
  grid-template-columns: 20px 1fr 32px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
}

.bs-rating-bar-row .progress { height: 8px; }

.bs-review-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.bs-review-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.bs-review-form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* Auth */
.bs-body-auth { background: var(--bg); }

.bs-auth {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.bs-auth-visual {
  background: linear-gradient(145deg, #6d28d9 0%, var(--primary) 50%, #a78bfa 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 3rem;
}

.bs-auth-visual h1 {
  font-size: 2rem;
  font-weight: 800;
  margin: 1rem 0;
}

.bs-auth-visual p { opacity: 0.9; line-height: 1.6; }

.bs-logo-lg {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
}

.bs-auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--card);
}

.bs-auth-panel {
  width: 100%;
  max-width: 400px;
}

/* App layout (cabinet) */
.bs-body-app { background: var(--bg); }

.bs-app {
  display: flex;
  min-height: 100vh;
}

.bs-sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.bs-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.bs-sidebar-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.bs-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: all var(--transition);
}

.bs-sidebar-nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.bs-sidebar-nav a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.bs-app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bs-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.bs-topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.bs-topbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.bs-topbar-search input {
  padding-left: 2.25rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.bs-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.bs-app-content {
  padding: 1.5rem;
  flex: 1;
}

.bs-page-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.bs-profile-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.bs-profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-soft);
}

.bs-stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
}

.bs-stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.bs-stat-card i.bi:first-child {
  font-size: 1.5rem;
  color: var(--primary);
}

.bs-stat-card strong {
  display: block;
  font-size: 1.5rem;
}

.bs-stat-card span {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.bs-stat-card .bi-chevron-right {
  margin-left: auto;
  color: var(--text-muted);
}

.bs-panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

/* Footer */
.bs-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: auto;
}

.bs-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.bs-footer a:hover { color: var(--primary); }

/* Admin */
.bs-body-admin { background: var(--bg); }

.bs-admin-wrap {
  display: flex;
  min-height: 100vh;
}

.bs-admin-sidebar {
  width: 220px;
  background: #1f2937;
  color: #fff;
  padding: 1.5rem 1rem;
}

.bs-admin-sidebar a {
  display: block;
  color: #d1d5db;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
}

.bs-admin-sidebar a:hover {
  background: rgba(139, 92, 246, 0.3);
  color: #fff;
}

.bs-admin-sidebar hr {
  border-color: #374151;
  margin: 1rem 0;
}

.bs-admin-main {
  flex: 1;
  padding: 2rem;
}

.bs-admin-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.bs-admin-stat span {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.bs-admin-stat strong {
  font-size: 2rem;
  color: var(--primary);
}

/* Responsive */
@media (max-width: 991.98px) {
  .bs-auth { grid-template-columns: 1fr; }
  .bs-auth-visual { display: none; }
  .bs-sidebar {
    position: fixed;
    z-index: 1040;
    height: 100%;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .bs-sidebar.show { transform: translateX(0); }
  .bs-hero-search { flex-direction: column; }
}

@media (max-width: 575.98px) {
  .bs-book-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .bs-reviews-section { padding: 1.25rem; }
}
