:root {
  --bg: #001233;
  --panel: #002855;
  --card: #003366;
  --text: #e6f2ff;
  --muted: #a0b0c0;
  --accent: #00aaff;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.5);
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Arial, sans-serif;
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(90deg, #001f4d, #002855);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.left-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 170, 255, 0.1);
}

.search-center {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 6px;
  align-items: center;
}

input[type="text"].main-search {
  width: 100%;
  max-width: 600px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #002855, #001f4d);
  color: var(--text);
  outline: none;
  font-size: 1rem;
}

input.main-search::placeholder {
  color: var(--muted);
}

.right-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.popover {
  position: absolute;
  background: linear-gradient(180deg, #002855, #001f4d);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow);
  display: none;
  z-index: 60;
  min-width: 160px;
}

.popover h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--accent);
}

.popover label {
  display: block;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--text);
  font-size: 0.85rem;
}

.popover input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.popover-actions {
  margin-top: 8px;
  text-align: right;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

main {
  padding: 10px 12px 80px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  align-items: start;
}

.card {
  background: linear-gradient(180deg, #003366, #002855);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-inner {
  display: flex;
  flex-wrap: wrap;
}

.card-media {
  flex: 0 0 100px;
  min-width: 100px;
  height: 100px;
  object-fit: cover;
  background: #001f4d;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-text {
  padding: 10px;
  flex: 1 1 160px;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
}

.card-title {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.card-body {
  color: var(--text);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.visit-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.tag {
  background: rgba(0, 170, 255, 0.1);
  border: 1px solid rgba(0, 170, 255, 0.15);
  color: var(--accent);
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.card.text-only .card-inner {
  display: block;
}

.card.text-only .card-text {
  padding: 12px;
}

.ad-slot-empty {
  background: linear-gradient(90deg, #002855, #001f4d);
  border: 1px dashed rgba(255, 255, 255, 0.05);
  min-height: 160px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 20px 0;
}

.loading-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0;
  animation: blink 1s infinite;
}

.loading-dots .dot:nth-child(1) { animation-delay: 0s; }
.loading-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    gap: 8px;
  }

  .left-controls {
    justify-content: center;
    width: 100%;
  }

  .search-center {
    width: 100%;
    justify-content: center;
  }

  .right-controls {
    justify-content: center;
    width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card-media {
    width: 100%;
    height: 180px;
    flex-basis: 100%;
  }

  .card-text {
    flex-basis: 100%;
  }
}

.controls-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.splash-screen {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.splash-content {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 1rem;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 0 15px var(--shadow);
}

.splash-content h2 {
  margin-top: 0;
  color: var(--accent);
}

.splash-screen[aria-hidden="true"] {
  display: none;
}

.splash-content p {
  margin: 1rem 0;
  line-height: 1.4;
  font-size: 0.95rem;
}

.splash-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.splash-note a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.splash-note a:hover {
  text-decoration: underline;
}

.splash-btn {
  margin-top: 1.5rem;
  padding: 8px 16px;
  font-size: 0.95rem;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.splash-btn:hover {
  background: #0088cc;
}