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

:root {
  --bg: #000000;
  --bg-soft: #050505;
  --bg-elevated: #0a0a0a;
  --bg-card: #0d0d0d;
  --text: #ffffff;
  --text-soft: #e5e7eb;
  --text-muted: #b3b3b3;
  --accent: #8ab4ff;
  --accent-hover: #a8c7ff;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #000000;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-content {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-menu a {
  color: var(--text-muted);
  transition: 0.2s ease;
}

.nav-menu a:hover {
  color: var(--text);
}

/* Hero */
.hero {
  padding: 88px 0 56px;
}

.hero-content {
  max-width: 760px;
}

.hero-tag {
  display: inline-block;
  margin-bottom: 16px;
  padding: 8px 14px;
  background: rgba(138, 180, 255, 0.1);
  color: #d9e7ff;
  border: 1px solid rgba(138, 180, 255, 0.2);
  border-radius: 999px;
  font-size: 0.95rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1.05;
  margin-bottom: 18px;
  letter-spacing: -0.03em;
}

.hero-text {
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.75;
  max-width: 620px;
  margin-bottom: 28px;
}

/* Search form */
.search-form {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(10, 10, 10, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.search-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  padding: 12px 14px;
}

.search-form input::placeholder {
  color: #9ca3af;
}

.search-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: 0.2s ease;
}

.search-form button:hover {
  background: var(--accent-hover);
}

/* Categories */
.categories {
  padding: 12px 0 36px;
}

.categories h2,
.results h2 {
  font-size: 1.6rem;
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.category-btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.96);
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}

.category-btn:hover {
  background: rgba(138, 180, 255, 0.12);
  border-color: rgba(138, 180, 255, 0.3);
  color: #dbe8ff;
}

/* Results */
.results {
  padding: 24px 0 64px;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading p {
  color: var(--text-soft);
  line-height: 1.65;
}

.books-grid:empty::after {
  content: "No books yet. Search something to begin.";
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  color: var(--text-soft);
  background: rgba(8, 8, 8, 0.95);
}

/* Responsive */
@media (max-width: 720px) {
  .nav-content {
    flex-direction: column;
    justify-content: center;
    padding: 14px 0;
  }

  .nav-menu {
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero {
    padding-top: 64px;
  }

  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form button {
    width: 100%;
  }

  .modal-body {
    flex-direction: column;
  }

  .modal-cover img {
    width: 100%;
    max-width: 220px;
  }
}

.book-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: rgba(138, 180, 255, 0.32);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.55);
}

.book-card:hover .book-cover img {
  transform: scale(1.04);
}

.book-info {
  padding: 14px;
}

.book-author {
  font-size: 0.95rem;
  color: var(--text-soft);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-year {
  font-size: 0.88rem;
  color: var(--accent);
}

.category-btn.active {
  background: rgba(138, 180, 255, 0.14);
  border-color: rgba(138, 180, 255, 0.38);
  color: #dbe8ff;
  box-shadow: 0 10px 24px rgba(138, 180, 255, 0.1);
}

.book-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-cover {
  width: 100%;
  aspect-ratio: 3 / 4.4;
  border-radius: 12px;
  background: linear-gradient(90deg, #070707 25%, #141414 50%, #070707 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite;
}

.skeleton-text {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #070707 25%, #141414 50%, #070707 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite;
}

.skeleton-text.small {
  width: 60%;
}

@keyframes skeleton-loading {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

.book-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.book-modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: min(700px, 90%);
  z-index: 10;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
}

.modal-body {
  display: flex;
  gap: 24px;
}

.modal-cover img {
  width: 160px;
  border-radius: 10px;
}

.modal-info h2 {
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.modal-info p {
  color: var(--text-soft);
  margin-bottom: 6px;
}

.modal-extra {
  margin-top: 20px;
}

.modal-extra h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--text);
}

#modalDescription {
  margin-bottom: 18px;
}

.repo-section {
  margin-top: 48px;
}

.repo-heading {
  margin-bottom: 18px;
}

.repo-card:hover {
  transform: translateY(-4px);
  border-color: rgba(138, 180, 255, 0.32);
}

.repo-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.repo-title a {
  color: var(--text);
}

.repo-title a:hover {
  color: #dbe8ff;
}

.repo-stars {
  white-space: nowrap;
  color: var(--accent);
  font-size: 0.9rem;
}

.repo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.repo-language {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(138, 180, 255, 0.1);
  border: 1px solid rgba(138, 180, 255, 0.2);
  color: #dbe8ff;
  font-size: 0.88rem;
}

.repo-empty {
  color: var(--text-soft);
  padding: 12px 0;
}

.repo-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(8, 8, 8, 0.95);
}

.article-section {
  margin-top: 48px;
}

.article-heading {
  margin-bottom: 18px;
}

.article-card:hover {
  transform: translateY(-4px);
  border-color: rgba(138, 180, 255, 0.32);
}

.article-title a {
  color: var(--text);
}

.article-title a:hover {
  color: #dbe8ff;
}

.article-author {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.article-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(138, 180, 255, 0.1);
  border: 1px solid rgba(138, 180, 255, 0.2);
  color: #dbe8ff;
  font-size: 0.82rem;
}

.article-empty {
  color: var(--text-soft);
  padding: 12px 0;
}

.article-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(8, 8, 8, 0.95);
}

.resource-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.resource-tab {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.96);
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
}

.resource-tab:hover {
  background: rgba(138, 180, 255, 0.12);
  border-color: rgba(138, 180, 255, 0.3);
  color: #dbe8ff;
}

.resource-tab.active {
  background: rgba(138, 180, 255, 0.14);
  border-color: rgba(138, 180, 255, 0.38);
  color: #dbe8ff;
  box-shadow: 0 10px 24px rgba(138, 180, 255, 0.1);
}

.is-hidden {
  display: none;
}

/* =========================
   CARD FIXES FINAL
========================= */

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  align-items: start;
}

.repo-grid,
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: stretch;
}

/* BOOK */
.book-card {
  background: #0a0a0a;
  border: 1px solid #1f1f1f;
  border-radius: 18px;
  overflow: hidden;
  min-width: 0;
  height: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #111;
  overflow: hidden;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.book-info {
  padding: 14px;
  min-width: 0;
}

.book-title {
  margin: 0 0 8px;
  color: #fff;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.95rem;
  color: var(--text-soft);
  margin-bottom: 6px;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-year {
  font-size: 0.88rem;
  color: var(--accent);
}

/* REPO */
.repo-card {
  background: #0a0a0a;
  border: 1px solid #1f1f1f;
  border-radius: 18px;
  padding: 18px;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.repo-title {
  margin: 0 0 10px;
  color: #fff;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-description {
  margin: 0 0 14px;
  color: #d4d4d4;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
}

/* ARTICLE */
.article-card {
  background: #0a0a0a;
  border: 1px solid #1f1f1f;
  border-radius: 18px;
  padding: 18px;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.article-title {
  margin: 0 0 10px;
  color: #fff;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-description {
  margin: 0 0 12px;
  color: #d4d4d4;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;

  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.modal-ai-section {
  margin: 20px 0 18px;
}

.modal-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.ai-summary-btn {
  border: 1px solid rgba(138, 180, 255, 0.24);
  background: rgba(138, 180, 255, 0.1);
  color: #e8f0ff;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.ai-summary-btn:hover {
  background: rgba(138, 180, 255, 0.18);
  border-color: rgba(138, 180, 255, 0.36);
}

.ai-summary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-summary-box {
  border: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.96);
  border-radius: 14px;
  padding: 14px 16px;
}

.ai-summary-box p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
  white-space: pre-line;
}

.hidden {
  display: none !important;
}

.modal-translate-section {
  margin: 18px 0 18px;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.96);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.lang-btn:hover {
  color: var(--text);
  background: rgba(138, 180, 255, 0.08);
}

.lang-btn.active {
  background: rgba(138, 180, 255, 0.14);
  color: #dbe8ff;
}

/* FOOTER */
.footer {
  border-top: 1px solid rgba(255,255,255,0.10);
  padding: 26px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: rgb(255, 255, 255);
}

.footer a {
  color: rgb(255, 255, 255);
  text-decoration: none;
}
.footer a:hover { color: white; }

.social {
  display: flex;
  gap: 18px;
}
