:root {
  --bg: #121317;
  /* new background color */
  --card: #1e293b;
  --text: #e2e8f0;
  --accent: #3b82f6;
  --modal-bg: rgba(0, 0, 0, 0.85);
  --tab-active: #3b82f6;
  --tab-hover: #1d4ed8;
}


body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 2rem;
  line-height: 1.6;
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.card .title {
  font-size: 1.3rem;
  font-weight: 700;
  flex: 1;
  /* ?? THIS FIXES YOUR ISSUE */
  min-width: 0;
  word-break: break-word;
}



.desc {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  min-height: 3em;
}

.meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: #334155;
  color: #cbd5e1;
}

.badge.version {
  background: var(--accent);
  color: white;
}

.badge.downloads {
  background: #10b981;
  color: white;
}

.search-box {
  margin-bottom: 2rem;
  text-align: center;
}

.search-box input {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  width: 300px;
  max-width: 90%;
}

.empty {
  text-align: center;
  color: #64748b;
  font-size: 1.2rem;
  padding: 4rem 1rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-bg);
  overflow-y: auto;
  /* Allow scrolling if modal is too tall */
}

.latest-version-badge {
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.modal-content {
  background: #020617;
  margin: 5% auto;
  padding: 2rem;
  border-radius: 12px;
  max-width: 1000px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  /* Scroll content if too long */
  max-height: 90vh;
  /* Prevent overflowing viewport */
}

.close {
  color: #94a3b8;
  float: right;
  font-size: 2.5rem;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: white;
}

.modal-title {
  font-size: 2.2rem;
  margin: 0 0 1rem;
  color: var(--accent);
}

.tabs-wrapper {
  max-width: 1000px;
  margin: 0 auto 2.5rem;
  padding: 0 1rem;
}


.tabs {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
  margin-bottom: 1.5rem;
  padding: 0.8rem 1.5rem;
  cursor: pointer;
}

.tab.active {
  color: white;
  border-bottom: 3px solid var(--tab-active);
}

.tab:hover {
  color: white;
  background: #1e293b;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.version-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.version-tag {
  background: #2563eb;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.screenshot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.screenshot {
  max-width: 300px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.screenshot-desc {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-top: 0.5rem;
  text-align: center;
}

pre {
  background: #242b32;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
}

/* Hide class */
.hidden {
  display: none !important;
}

.detail-header {
  position: relative;
  margin-bottom: 2.5rem;
  /* ? fills space before markdown */
}

.detail-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;

  display: flex;

  gap: 1rem;
  /* ? spacing between items */
}

#detailTitle {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.back-button {
  background: none;
  border: none;
  color: #e5e7eb;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0;
  position: absolute;
  left: 0;
}


.back-button:hover {
  color: #93c5fd;
}

.back-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}



/* Make detail content look good full-width */
#detailContent {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}


/* === FIX GitHub Markdown black background === */
.markdown-body {
  background: transparent !important;
  color: var(--text);
  padding: 0;
}

/* Code blocks inside markdown */
.markdown-body pre {
  background: #020617;
  /* keep dark background */
  color: #242b32;
  /* new font color */
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9rem;
  white-space: pre-wrap;
  /* optional: wrap long lines */
}

/* Inline code */
.markdown-body code {
  background: #1e293b;
  color: #e5e7eb;
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Blockquotes */
.markdown-body blockquote {
  border-left: 4px solid #334155;
  color: #cbd5e1;
  background: transparent;
}

/* Tables */
.markdown-body table {
  background: transparent;
}

.markdown-body th,
.markdown-body td {
  border-color: #334155;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  flex-wrap: nowrap;
}

.version-prefix {
  background: #2563eb;
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.copy-btn {
  background: #334155;
  border: none;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.copy-btn:hover {
  background: #475569;
}

.pagination {
  margin: 3rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
}

.pagination button {
  background: #334155;
  border: none;
  color: #e5e7eb;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination span {
  font-size: 0.9rem;
  color: #94a3b8;
}

.detail-header-inner {
  display: flex;
  flex-direction: column;

  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;

}

.header-top {
  display: flex;
  align-items: center;

  gap: 1rem;
  /* spacing between name, version, copy */
  flex-wrap: wrap;
  /* wrap if too narrow */
}

#detailTitle {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

#latestVersion {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--accent);
}

.platforms-container {
  margin-top: 4px;
  /* small gap below line 1 */
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  /* wrap if too many platforms */
}

.platform-badge {
  background-color: #334155;
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: capitalize;
  white-space: nowrap;
}

/* Top bar like pub.dev */
.top-bar {
  background: #0f172a;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #1e293b;
}

.top-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-dot {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
}

.logo-text {
  font-weight: 600;
  color: #e5e7eb;
  font-size: 1.1rem;
}

.search-wrapper {
  flex: 1;
}

.search-wrapper input {
  width: 100%;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #1e293b;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.9rem;
}

/* Layout */
.main-layout {
  max-width: 960px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.results-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.results-info {
  margin-top: 0.25rem;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* Package cards similar to pub.dev */
.packages-list {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.package-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: #020617;
  border: 1px solid #1e293b;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.package-card:hover {
  border-color: #3b82f6;
  background: #020818;
}

.package-card-main {
  flex: 1;
  min-width: 0;
}

.package-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.package-name {
  font-weight: 600;
  color: #e5e7eb;
  text-decoration: none;
  font-size: 1rem;
}

.package-name:hover {
  text-decoration: underline;
}

.package-version {
  font-size: 0.8rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #1e293b;
  color: #e5e7eb;
}

.package-desc {
  margin: 0.25rem 0 0.4rem;
  color: #9ca3af;
  font-size: 0.9rem;
}

.package-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  color: #6b7280;
  font-size: 0.8rem;
}

.meta-divider {
  opacity: 0.6;
}

.package-card-actions {
  display: flex;
  align-items: center;
}

.install-btn {
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #3b82f6;
  color: white;
}

.install-btn:hover {
  background: #2563eb;
}