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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  overflow: hidden;
  height: 100vh;
}

#root {
  width: 100%;
  height: 100vh;
}

/* --- Top bar --- */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 0.75rem 1rem;
  background: transparent;
  pointer-events: none;
}

.top-bar * {
  pointer-events: auto;
}

.search-bar {
  display: flex;
  gap: 0.4rem;
  max-width: 600px;
  margin: 0 auto;
  align-items: center;
}

.search-bar input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 4px;
  color: #e0e0e0;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: #555;
}

.search-bar button[type="submit"] {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  background: rgba(26, 26, 26, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
  transition: background 0.2s;
}

.search-bar button[type="submit"]:hover {
  background: rgba(42, 42, 42, 0.9);
}

.clear-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

.clear-btn:hover { color: #ccc; }

.filter-btn {
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 4px;
  color: #666;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  transition: color 0.2s;
}

.filter-btn:hover { color: #ccc; }

/* --- Filter panel --- */

.filter-panel {
  max-width: 600px;
  margin: 0.5rem auto 0;
  background: rgba(20, 20, 20, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #222;
  border-radius: 6px;
  padding: 0.5rem;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: #bbb;
  cursor: pointer;
}

.filter-item:hover { color: #fff; }

.filter-item input { accent-color: #666; }

.filter-count {
  color: #555;
  margin-left: auto;
  font-size: 0.7rem;
}

.filter-only {
  background: none;
  border: 1px solid transparent;
  background-color: #555;
  color: #fff;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.filter-item:hover .filter-only { opacity: 1; }

.filter-only:hover {
  color: #ccc;
  border-color: #444;
}

/* --- Infinite canvas --- */

.viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.viewport:active { cursor: grabbing; }

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

/* --- Cards --- */

.card {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-radius: 2px;
  transition: transform 0.15s;
}

.card:hover { transform: scale(1.02); z-index: 2; }

.card-thumb {
  position: relative;
  width: 100%;
  height: 100%;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

.card-placeholder {
  width: 100%;
  height: 100%;
  background: #111;
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.8rem 0.5rem 0.4rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  cursor: pointer;
}

.card-text {
  font-size: 0.7rem;
  line-height: 1.3;
  color: rgba(255,255,255,0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  background: rgba(0,0,0,0.65);
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
}

.card-overlay:hover .card-text {
  text-decoration: underline;
}

.similar-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: rgba(0,0,0,0.5);
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767px) {
  .similar-btn { display: flex; }
}

/* --- Video overlay --- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.overlay-content {
  display: flex;
  width: 92%;
  max-width: 1200px;
  max-height: 90vh;
  gap: 1.5rem;
  position: relative;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  padding: 1.5rem;
}

.close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: #666;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
}

.close-btn:hover { color: #fff; }

.overlay-player {
  flex: 0 0 85%;
  min-width: 0;
  align-self: center;
}

.overlay-player video {
  width: 100%;
  border-radius: 4px;
}

.yt-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
}

.yt-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.overlay-info {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding-top: 0.5rem;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.overlay-info::-webkit-scrollbar { display: none; }

.overlay-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #ddd;
}

.overlay-time {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.overlay-transcript {
  font-size: 0.85rem;
  color: #999;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.overlay-context {
  font-size: 0.85rem;
  font-style: italic;
  color: #777;
  line-height: 1.5;
}

.overlay-collection {
  font-size: 0.7rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.overlay-action-btn {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #999;
  text-decoration: none;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  transition: color 0.2s, border-color 0.2s;
}

.overlay-action-btn:hover {
  color: #fff;
  border-color: #555;
}

.video-loading {
  width: 100%;
  padding-bottom: 56.25%;
  position: relative;
}
.video-loading .spinner {
  position: absolute;
  top: calc(50% - 16px);
  left: calc(50% - 16px);
}

/* --- Loading spinner --- */

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid #333;
  border-top-color: #888;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: #555;
  font-size: 0.8rem;
}

/* --- About button & overlay --- */

.about-btn {
  background: rgba(10, 10, 10, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #333;
  border-radius: 4px;
  color: #666;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  transition: color 0.2s;
  font-weight: 500;
}

.about-btn:hover { color: #ccc; }

.about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.about-content {
  background: #141414;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  position: relative;
  color: #bbb;
  font-size: 0.9rem;
  line-height: 1.6;
}

.about-content h2 {
  font-size: 1.1rem;
  color: #ddd;
  margin-bottom: 1rem;
  font-weight: 500;
}

.about-content p {
  margin-bottom: 0.75rem;
}

.about-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: #666;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.about-close:hover { color: #fff; }

/* --- Status --- */

.status {
  grid-column: 1 / -1;
  text-align: center;
  color: #444;
  padding: 3rem;
  font-size: 0.9rem;
}

/* --- Mobile --- */

@media (max-width: 768px) {
  .overlay-content {
    flex-direction: column;
    width: 100%;
    max-height: none;
    padding: 0.5rem;
    gap: 0.75rem;
  }

  .overlay-player {
    flex: none;
    width: 100%;
  }

  .overlay-info {
    padding: 0 0.5rem 1rem;
    overflow-y: visible;
  }

  .close-btn {
    top: 0.25rem;
    right: 0.5rem;
  }
}

a {
  color: purple;
}
