:root {
  --bg: #0b0f19;
  --card: #111827;
  --muted: #6b7280;
  --text: #e5e7eb;
  --pri: #60a5fa;
  --pri-2: #93c5fd;
  --ring: #3b82f6;
  --card-h: #1f2937;
  --chip: #0f172a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --star-inactive: #4b5563; /* Gray */
  --star-active: #facc15; /* Yellow */
  --sidebar-width: 240px;
}

html[data-theme='light'] {
  --bg: #f8fafc;
  --card: #ffffff;
  --card-h: #f3f4f6;
  --text: #0f172a;
  --muted: #475569;
  --chip: #e5e7eb;
  --shadow: 0 8px 20px rgba(2, 6, 23, .08);
  --star-inactive: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", sans-serif;
  writing-mode: horizontal-tb;
  transition: margin-left 0.3s ease; /* Added transition */
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(140%) blur(8px);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pri), var(--pri-2));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  font-weight: 800;
  color: #0b1220;
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}

.btn:hover {
  background: var(--card-h);
}

.search {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  padding: 8px 12px;
  border-radius: 14px;
  flex: 1;
  max-width: 520px;
}

.search input {
  all: unset;
  flex: 1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.cards-wrap {
  grid-column: 1 / -1;
}

#cards.cards-wrap,
#testing-cards.cards-wrap,
#article-cards.cards-wrap {
  grid-column: 1 / -1; /* Ensure all wraps span full width */
}

.card {
  grid-column: span 4;
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.thumb {
  height: 120px;
  background: var(--card-h);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 40px; /* Added font-size for emoji */
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Adjust object-fit as needed */
}

.card .body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1; /* Added flex-grow */
}

.card .actions {
  margin-top: auto; /* Push actions to the bottom */
}

.tag {
  font-size: 12px;
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--muted);
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--pri) 20%, transparent);
  border: 1px solid var(--pri);
  color: var(--pri-2);
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.launch,
.comment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  margin-left: 5px;
}

.launch {
  background: var(--pri);
  color: #0b1220;
}

.comment-btn {
  background: var(--card-h);
  color: var(--text);
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  color: var(--text);
  cursor: pointer;
  margin-left: 5px;
}

.ads {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px dashed color-mix(in oklab, var(--text) 18%, transparent);
  border-radius: 16px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
}

/* Button Alignment Fix */
.card .actions a,
.card .actions button {
  min-width: 70px; /* Adjust this value as needed */
  text-align: center;
  margin-bottom: 5px; /* Add space if buttons wrap */
  margin-right: 5px; /* Add space between buttons */
  margin-left: 0; /* Override default margin */
}
.card .actions a:first-child,
.card .actions button:first-child {
  margin-left: 0; /* Ensure first button aligns left */
}

/* Comment Modal Styles */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px); }
.modal-content { background-color: var(--card); margin: 10% auto; padding: 25px; border: 1px solid color-mix(in oklab,var(--text) 12%, transparent); width: 80%; max-width: 600px; border-radius: 12px; position: relative; }
.modal-close { color: var(--muted); position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-close:hover, .modal-close:focus { color: var(--text); text-decoration: none; }
.modal h2 { margin-top: 0; color: var(--pri); }
#commentForm label { display: block; margin: 10px 0 5px; font-weight: 600; font-size: 0.9em; color: var(--muted); }
#commentForm input[type=text], #commentForm input[type=email], #commentForm textarea { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid color-mix(in oklab,var(--text) 20%, transparent); background-color: var(--bg); color: var(--text); border-radius: 8px; font-family: inherit; }
#commentForm textarea { resize: vertical; min-height: 80px; }
#commentForm button[type=submit] { background-color: var(--pri); color: var(--bg); padding: 10px 15px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }
#commentForm button[type=submit]:hover { filter: brightness(1.1); }
.star-rating { display: flex; gap: 2px; cursor: pointer; margin-bottom: 10px; }
.star { font-size: 24px; color: var(--star-inactive); }
.star.active { color: var(--star-active); }
#commentMsg { margin-top: 10px; color: var(--pri-2); font-size: 0.9em; }
#commentsList { margin-top: 30px; border-top: 1px solid color-mix(in oklab,var(--text) 12%, transparent); padding-top: 20px; max-height: 300px; overflow-y: auto;}
#commentsList h3 { color: var(--pri-2); margin-bottom: 1rem; }
.comment-item{background:#1f2937;padding:.75rem 1rem;border-radius:8px;margin-bottom:.5rem}
.comment-item strong{color:#93c5fd}
.comment-item small{color:#9ca3af;font-size:.8em; margin-left: 5px;}
.comment-item .stars{color:#facc15; margin-left: 5px;}
.comment-item p { margin: 5px 0 0; color: var(--muted); font-size: 0.95em; word-wrap: break-word; }

/* Sidebar Styles */
.sidebar { height: 100%; width: 0; position: fixed; z-index: 101; top: 0; left: 0; background-color: var(--card); overflow-x: hidden; transition: 0.3s ease; padding-top: 60px; border-right: 1px solid color-mix(in oklab,var(--text) 12%, transparent); }
.sidebar a { padding: 10px 15px 10px 32px; text-decoration: none; font-size: 18px; color: var(--muted); display: block; transition: 0.2s; white-space: nowrap; }
.sidebar a:hover, .sidebar a.active { color: var(--pri-2); background-color: color-mix(in oklab,var(--pri) 10%, transparent); }
.sidebar .closebtn { display: none; }
.sidebar-toggle { font-size: 24px; cursor: pointer; color: var(--text); background: none; border: none; padding: 0 10px; display: block; }

/* Main content adjustment */
.main-content { transition: margin-left .3s ease; padding: 16px; }
body.sidebar-open .sidebar { width: var(--sidebar-width); }
body.sidebar-open .main-content { margin-left: var(--sidebar-width); }
@media (min-width: 981px) { .sidebar-toggle { display: none; } .sidebar { width: var(--sidebar-width); padding-top: 70px; } .main-content { margin-left: var(--sidebar-width); } body.sidebar-open .main-content { margin-left: var(--sidebar-width); } }
@media (max-width: 980px) { body:not(.sidebar-open) .main-content { margin-left: 0; } }

/* Helper class */
.hidden { display: none !important; }

/* Introduction Section Style */
#intro-section { background: var(--card); padding: 20px; border-radius: 12px; margin-bottom: 20px; border: 1px solid color-mix(in oklab,var(--text) 12%, transparent); }
#intro-section h2 { margin-top: 0; color: var(--pri); }

.section-separator { border: 0; height: 1px; background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--muted), rgba(0, 0, 0, 0)); margin: 2rem 0; }

@media (max-width:980px){.card{grid-column:span 6}}
@media (max-width:640px){.card{grid-column:span 12}}