:root {
  --primary: #6C63FF;
  --primary-dark: #5651e9;
  --accent: #00C9A7;
  --accent-dark: #00b896;
  --background-light: #F8F9FA;
  --background-dark: #121212;
  --text-light: #2A2A2A;
  --text-dark: #EDEDED;
  --card-light: #FFFFFF;
  --card-dark: #1E1E2F;
  --radius: 16px;
  --shadow-soft: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-strong: 0 10px 30px rgba(0,0,0,0.15);
  --transition: 0.3s ease;
  --header-height: 280px;

  /* overlay active category background (set dynamically from JS) */
  --active-cat-bg: linear-gradient(45deg, var(--primary), var(--accent));
}

/* Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  transition: background 1.2s ease-in-out, color 1.2s ease-in-out;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Theme-specific styles using data-theme attribute */
[data-theme="light"] {
  background-color: var(--background-light);
  color: var(--text-light);
}

[data-theme="dark"] {
  background-color: var(--background-dark);
  color: var(--text-dark);
}

/* Tema almashuvi animatsiyasi - maksimal silliq */
html.theme-transitioning,
html.theme-transitioning * {
  transition: background-color 1.2s ease-in-out, 
              color 1.2s ease-in-out, 
              border-color 1.2s ease-in-out,
              box-shadow 1.2s ease-in-out,
              background 1.2s ease-in-out !important;
}

html.theme-transitioning body::before {
  transition: background 1.2s ease-in-out, opacity 1.2s ease-in-out !important;
}

html.theme-transitioning header {
  transition: background 1.2s ease-in-out, box-shadow 1.2s ease-in-out !important;
}

html.theme-transitioning header::after {
  transition: background 1.2s ease-in-out !important;
}

/* Animatsiyalangan orqa fon */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: 400% 400%;
  animation: gradientBackground 15s ease infinite;
  z-index: -1;
  transition: opacity 0.5s ease;
}

[data-theme="light"] body::before {
  background: linear-gradient(45deg, #6C63FF, #00C9A7, #6C63FF);
  opacity: 0.03;
}

[data-theme="dark"] body::before {
  background: linear-gradient(45deg, #1c1c2e, #2d2d4d, #1c1c2e);
  animation: gradientBackgroundDark 20s ease infinite;
  opacity: 0.2;
}

@keyframes gradientBackground {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes gradientBackgroundDark {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Splash Screen */
#splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#splashTitle {
  font-size: 3.5rem;
  color: #fff;
  margin-bottom: 1rem;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  animation: splashTitleAnimation 1.2s ease-out forwards;
}
#splashSubtitle {
  font-size: 1.5rem;
  color: #fff;
  opacity: 0.9;
  animation: splashSubtitleAnimation 1.2s ease-out 0.3s forwards;
}
@keyframes splashTitleAnimation {
  from { transform: translateY(-50px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes splashSubtitleAnimation {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.splash-fade-out {
  animation: splashFadeOut 0.8s forwards;
}
@keyframes splashFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* Header */
header {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #fff;
  box-shadow: var(--shadow-soft);
  position: relative;
  min-height: var(--header-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: headerSlideDown 1s ease-out;
  transition: background 1.2s ease-in-out, box-shadow 1.2s ease-in-out;
}

[data-theme="light"] header {
  background: linear-gradient(135deg, #6C63FF, #00C9A7);
}

[data-theme="dark"] header {
  background: linear-gradient(135deg, #5651e9, #00b896);
}
@keyframes headerSlideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to bottom, transparent, var(--background-light));
  z-index: 1;
}
[data-theme="dark"] header::after {
  background: linear-gradient(to bottom, transparent, var(--background-dark));
}
header h1 {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
header .subtitle {
  opacity: 0.9;
  margin-top: 0.5rem;
  font-size: 1.2rem;
  margin-left: auto;
  margin-right: auto;
}
.header-actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
  z-index: 2;
  position: relative;
}
.header-actions input {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  width: 320px;
  font-size: 1rem;
  box-shadow: var(--shadow-soft);
  transition: all 0.6s ease, background 0.6s ease, color 0.6s ease;
}
[data-theme="light"] .header-actions input {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-light);
}
[data-theme="dark"] .header-actions input {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.header-actions input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
  transform: translateY(-2px);
}
[data-theme="dark"] .header-actions input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}
[data-theme="light"] .header-actions input::placeholder {
  color: var(--text-light);
}
[data-theme="dark"] .header-actions input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Buttons */
.btn {
  cursor: pointer;
  padding: 0.9rem 1.8rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: all 0.6s ease, background 0.6s ease, color 0.6s ease;
  box-shadow: var(--shadow-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%);
  transform-origin: 50% 50%;
}
.btn:hover::after {
  animation: ripple 1s ease-out;
}
.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-strong);
}
.btn:active {
  transform: translateY(0);
}
@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 0.5;
  }
  100% {
    transform: scale(30, 30);
    opacity: 0;
  }
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-danger {
  background: #ff6b6b;
  color: #fff;
}
.btn-danger:hover {
  background: #ff5252;
}
.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
}
[data-theme="light"] .btn-ghost {
  background: rgba(0,0,0,0.05);
  color: var(--text-light);
  border: 1px solid rgba(0,0,0,0.1);
}
[data-theme="dark"] .btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .btn-primary {
  background: var(--primary-dark);
}
[data-theme="dark"] .btn-primary:hover {
  background: var(--primary);
}
[data-theme="dark"] .btn-danger {
  background: #e53935;
}
[data-theme="dark"] .btn-danger:hover {
  background: #d32f2f;
}

/* Categories & Cards */
.categories-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.8rem 1rem;
  position: relative;
  z-index: 2;
  transition: background 0.6s ease;
}
[data-theme="light"] .categories-row {
  background: rgba(108, 99, 255, 0.03);
}
[data-theme="dark"] .categories-row {
  background: rgba(255, 255, 255, 0.03);
}

/* Barcha kategoriya tugmalari va kitob kartochkalari bir xil ko'rinishda bo'ladi */
.category-btn {
  background: linear-gradient(45deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: 1rem 1.2rem;
  width: 50%;
  max-width: 100%;
  min-width: auto;
  font-size: 1.15rem;
  font-weight: 700;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius);
  text-align: center;
  justify-content: center;
  transition: all 0.6s ease, background 0.6s ease;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.card {
  background: linear-gradient(45deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: 1rem 1.5rem;
  width: 90%;
  max-width: 600px;
  margin: 0.5rem auto;
  min-height: 60px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.6s ease, background 0.6s ease;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  position: relative;
}

.card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-strong);
  filter: brightness(1.1);
}

.book-title {
  color: #fff;
  margin: 0;
  font-size: 1.1rem;
  white-space: normal;
  line-height: 1.3;
}

.card-actions {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  margin: 0;
  display: none;
  z-index: 10;
}

body.admin-mode .card-actions {
  display: flex;
  gap: 0.5rem;
}

body.admin-mode .card-actions .btn-danger {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}

body.admin-mode .card-actions .btn-danger:not(:hover) {
  pointer-events: auto;
}


.category-btn.active {
  box-shadow: 0 0 0 3px var(--accent);
  transform: translateY(-2px);
}
[data-theme="dark"] .category-btn,
[data-theme="dark"] .card {
  background: linear-gradient(45deg, var(--primary-dark), var(--accent-dark));
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-strong);
}

.book-title {
  color: #fff;
  margin: 0;
  font-size: 1.1rem;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-desc,
.book-category,
.card-actions {
  display: none;
}

/* Admin rejimda ko'rsatish */
body.admin-mode .card-actions {
  display: block;
  margin-top: 1rem;
}

.grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  width: 100%;
}

/* Admin mode books display */
body.admin-mode #booksContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 60%;
  margin: 0 auto;
}

body.admin-mode .card {
  width: 100%;
  max-width: 100%;
}

/* Centered Admin Button */
.center {
  text-align: center;
  margin: 2.5rem 0;
}

/* Upload Section */
#uploadSection {
  width: 100%;
  max-width: 60%;
  margin: 0 auto 3.5rem;
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: all 0.6s ease, background 0.6s ease, border 0.6s ease;
}
[data-theme="light"] #uploadSection {
  background: var(--card-light);
}
[data-theme="dark"] #uploadSection {
  background: var(--card-dark);
  border: 1px solid #333;
}
#uploadSection h2 {
  margin-bottom: 1.8rem;
  text-align: center;
  font-size: 1.8rem;
}
[data-theme="light"] #uploadSection h2 {
  color: var(--primary);
}
[data-theme="dark"] #uploadSection h2 {
  color: var(--accent);
}
#uploadForm {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
#uploadForm input,
#uploadForm select {
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.6s ease, background 0.6s ease, color 0.6s ease, border 0.6s ease;
}

#bookDescription {
  display: none;
}
[data-theme="light"] #uploadForm input,
[data-theme="light"] #uploadForm select {
  border: 1px solid #ddd;
  background: #fff;
  color: var(--text-light);
}
[data-theme="dark"] #uploadForm input,
[data-theme="dark"] #uploadForm select {
  background: #2d2d2d;
  color: #e0e0e0;
  border: 1px solid #444;
}
#uploadForm input:focus,
#uploadForm select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}
#progressWrap {
  margin-top: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  height: 24px;
}
[data-theme="light"] #progressWrap {
  background: #f0f0f0;
}
[data-theme="dark"] #progressWrap {
  background: #2d2d2d;
}
#progressBar {
  background: linear-gradient(to right, var(--primary), var(--accent));
  height: 100%;
  width: 0%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: width 0.3s ease;
}
[data-theme="dark"] #progressBar {
  background: linear-gradient(to right, var(--primary-dark), var(--accent-dark));
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  z-index: 2001;
  padding: 1rem;
}
.modal.show {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  position: relative;
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  text-align: center;
  transform: translateY(30px) scale(0.95);
  transition: transform var(--transition), background 0.6s ease, color 0.6s ease;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
[data-theme="light"] .modal-content {
  background: var(--card-light);
  color: var(--text-light);
}
[data-theme="dark"] .modal-content {
  background: var(--card-dark);
  color: var(--text-dark);
  border: 1px solid #333;
}
.modal.show .modal-content {
  transform: translateY(0) scale(1);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  font-size: 1.8rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition);
}
.modal-close:hover {
  opacity: 1;
}
.modal-content h3 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}
.modal-content .btn {
  margin: 0.5rem;
  justify-content: center;
}

/* PDF Modal Kitob Nomi Konteyner */
#pdfModalBookContainer {
  background: rgba(108, 99, 255, 0.1) !important;
  border-left: 4px solid var(--primary) !important;
}
[data-theme="dark"] #pdfModalBookContainer {
  background: rgba(108, 99, 255, 0.15) !important;
  border-left-color: var(--accent) !important;
}

.modal-content .success-text {
  color: var(--accent);
  margin-top: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Admin Password Modal Input */
#adminPasswordInput {
  padding: 0.8rem 1rem !important;
  border-radius: 8px !important;
  border: 1px solid #ddd !important;
  width: 100% !important;
  margin-bottom: 1.5rem !important;
  font-size: 1rem !important;
  box-sizing: border-box !important;
  transition: all var(--transition);
}
[data-theme="light"] #adminPasswordInput {
  background: #fff;
  color: var(--text-light);
}
[data-theme="dark"] #adminPasswordInput {
  background: #2d2d2d;
  color: #e0e0e0;
  border-color: #444 !important;
}
#adminPasswordInput:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2) !important;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  background: var(--primary);
  color: #fff;
  margin-top: 3rem;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: background 0.6s ease, color 0.6s ease;
}
[data-theme="dark"] footer {
  background: var(--primary-dark);
}

/* Animations */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.reveal.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1024px) {
  .category-btn,
  .card {
    min-width: 140px;
    max-width: 200px;
    font-size: 1.05rem;
    padding: 0.95rem 1.5rem;
  }
}

/* Mobil qurilmalar (768px dan kichik) uchun */
@media (max-width: 768px) {
  .category-btn {
    font-size: 1.15rem;
    padding: 1.2rem 0.8rem;
    width: 95%;
    max-width: 95%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    min-height: 60px;
    height: auto;
    line-height: 1.4;
  }
  
  .card {
    font-size: 1rem;
    padding: 1rem 0.8rem;
    width: 95%;
    max-width: 95%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    min-height: 70px;
    height: auto;
  }
  
  header h1 {
    font-size: 2.2rem;
  }
  
  .header-actions {
    flex-direction: column;
    gap: 0.8rem;
  }
  
  .header-actions input {
    width: 100%;
  }
  
  .grid {
    grid-template-columns: 1fr;
    padding: 1.5rem;
    gap: 1.2rem;
  }
  
  .categories-row {
    padding: 1.2rem 0.5rem;
    gap: 0.7rem;
  }
  
  #uploadSection {
    padding: 1.5rem 1rem;
    margin: 1.5rem auto 2rem;
    max-width: 90%;
    width: 90%;
  }
  
  #uploadSection h2 {
    font-size: 1.4rem;
    margin-bottom: 1.2rem;
  }
  
  #uploadForm input,
  #uploadForm select {
    padding: 0.9rem 0.8rem;
    font-size: 1rem;
  }
  
  #uploadForm .btn-primary {
    padding: 1rem 1.2rem;
    font-size: 1rem;
  }

  #categoryOverlay .grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    max-width: 95%;
    margin: 0 auto;
  }
  
  #overlayTitle {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
  }
  
  body.admin-mode #booksContainer {
    max-width: 95%;
  }
  
  body.admin-mode .card {
    width: 100%;
    max-width: 100%;
  }
  
  .center {
    margin: 1.5rem 0;
  }
  
  .center .btn {
    width: 90%;
    max-width: 90%;
  }
}

/* Category Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 3rem 1rem;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease, background 0.6s ease;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
}
.overlay-content {
  width: 100%;
  animation: slideUp 0.5s ease forwards;
  --active-cat-bg: var(--active-cat-bg);
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
#overlayTitle {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 2rem;
}
#overlayBooks .card {
  animation: fadeIn 0.6s ease;
}

/* Overlay ichidagi kartochkalar uchun o'ziga xos stillar */
.overlay .card {
  background: linear-gradient(45deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: 1rem 1.2rem;
  width: 50%;
  max-width: 100%;
  min-width: auto;
  font-size: 1.15rem;
  font-weight: 700;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: var(--radius);
  text-align: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  position: relative;
}
.overlay .card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-strong);
}

.overlay .card .book-title {
  color: #fff;
  margin: 0;
  font-size: 1.5rem;
}

.overlay .card .book-desc,
.overlay .card .book-category {
  display: none;
}

.overlay .card .card-actions {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  margin: 0;
  display: none;
}

body.admin-mode .overlay .card .card-actions {
  display: block;
}

body.admin-mode .overlay .card .card-actions .btn-danger {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

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

/* Overlay kartochkalar uchun mobil moslashuv */
@media (max-width: 768px) {
  .overlay .card {
    width: 95%;
    max-width: 95%;
    min-height: 60px;
    height: auto;
    padding: 1.2rem 0.8rem;
    font-size: 1.15rem;
    line-height: 1.4;
  }
}

@media (max-width: 500px) {
  .overlay .card {
    width: 98%;
    max-width: 98%;
    min-height: 55px;
    padding: 1rem 0.6rem;
    font-size: 1rem;
  }
}

@media (max-width: 360px) {
  .overlay .card {
    width: 100%;
    max-width: 100%;
    min-height: 50px;
    padding: 0.9rem 0.5rem;
    font-size: 0.95rem;
  }
}

#categoryOverlay .grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 60%;
  margin: 0 auto;
}

#overlayBooks .card {
  width: 100%;
  max-width: 100%;
}

/* Ranglar ketma-ketligi + gradient + hover effekti */
.card:nth-child(12n+1),
.card:nth-child(12n+3),
.card:nth-child(12n+5) {
  background: linear-gradient(135deg, #F4B183, #f7c9a3);
}
.card:nth-child(12n+2),
.card:nth-child(12n+4),
.card:nth-child(12n+6) {
  background: linear-gradient(135deg, #FFE699, #fff2b3);
}
.card:nth-child(12n+7),
.card:nth-child(12n+9),
.card:nth-child(12n+11) {
  background: linear-gradient(135deg, #C6E0B4, #d6edc6);
}
.card:nth-child(12n+8),
.card:nth-child(12n+10),
.card:nth-child(12n+12) {
  background: linear-gradient(135deg, #D9D2E9, #e8e2f1);
}

/* Hover effekti */
.card:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25),
              0 0 20px rgba(255, 255, 255, 0.4);
  filter: brightness(1.1);
  transition: all 0.3s ease;
}

/* Book title rangini yaxshilash */
.book-title {
  color: #003366 !important;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

/* Mobil qurilmalar uchun moslashuv (takrori - o'chirib tashlaymiz) */

/* Kichik ekranlar (500px dan pastida) */
@media (max-width: 500px) {
  .category-btn {
    font-size: 1rem;
    padding: 1rem 0.6rem;
    width: 98%;
    max-width: 98%;
    min-height: 55px;
  }
  
  .card {
    font-size: 0.95rem;
    padding: 0.9rem 0.6rem;
    width: 98%;
    max-width: 98%;
    min-height: 65px;
  }
  
  .overlay .card {
    width: 98%;
    max-width: 98%;
    min-height: 65px;
  }
  
  header h1 {
    font-size: 1.8rem;
  }
  
  header .subtitle {
    font-size: 1rem;
  }
  
  .header-actions input {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
  }
  
  #uploadSection {
    padding: 1rem 0.8rem;
    max-width: 95%;
    width: 95%;
    margin: 1rem auto 1.5rem;
  }
  
  #uploadSection h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }
  
  #uploadForm input,
  #uploadForm select {
    padding: 0.8rem 0.6rem;
    font-size: 0.95rem;
  }
  
  #uploadForm .btn-primary {
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
  }
  
  #overlayTitle {
    font-size: 1.4rem;
    margin-bottom: 1.2rem;
  }
  
  body.admin-mode #booksContainer {
    max-width: 98%;
  }
  
  .center .btn {
    width: 95%;
    max-width: 95%;
    font-size: 0.95rem;
    padding: 0.9rem 1rem;
  }
  
  .book-title {
    font-size: 1rem;
    line-height: 1.4;
  }
  
  #categoryOverlay .grid .card {
    width: 95%;
  }
}

/* Juda kichik ekranlar (360px va pastida) */
@media (max-width: 360px) {
  header {
    min-height: 220px;
    padding: 1.5rem 0.5rem;
  }
  
  header h1 {
    font-size: 1.6rem;
  }

  .categories-row {
    padding: 0.8rem 0.3rem;
    gap: 0.5rem;
  }

  .category-btn {
    font-size: 0.9rem;
    padding: 0.8rem 0.4rem;
    width: 100%;
    max-width: 100%;
    min-height: 50px;
  }
  
  .card {
    font-size: 0.85rem;
    padding: 0.8rem 0.4rem;
    width: 100%;
    min-height: 60px;
  }

  .grid {
    gap: 0.8rem;
    padding: 0.8rem;
  }

  #uploadSection {
    padding: 0.8rem 0.6rem;
    margin: 0.8rem auto 1rem;
    max-width: 98%;
  }
  
  #uploadSection h2 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }
  
  #uploadForm input,
  #uploadForm select {
    padding: 0.7rem 0.5rem;
    font-size: 0.9rem;
  }
  
  #uploadForm .btn-primary {
    padding: 0.8rem 0.8rem;
    font-size: 0.9rem;
  }
  
  .center .btn {
    width: 98%;
    max-width: 98%;
    font-size: 0.9rem;
    padding: 0.8rem 0.8rem;
  }
  
  #overlayTitle {
    font-size: 1.2rem;
  }
  
  .modal-content {
    padding: 1.5rem 1rem;
  }
  
  .modal-content h3 {
    font-size: 1.1rem;
  }
}

/* Telefonlar uchun maxsus (siz aytgan 2-rasmdagi holatni tuzatish) */
@media (max-width: 480px) {
  .grid {
    gap: 0.8rem;
    padding: 0.5rem;
  }

  .card {
    width: 80%;
    max-width: 95%;
    min-height: 60px;
    font-size: 1rem;
    padding: 1rem;
  }

  .book-title {
    font-size: 1rem;
  }
}

