:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --shadow-header: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.05);

  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-pill: 999px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  /* Lock the screen height for laptop view */
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- 1. Compact Header --- */
.app-header {
  height: 64px;
  /* Fixed small height */
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-header);
  flex-shrink: 0;
  z-index: 10;
}

/* Left: Logo */
.header-left {
  flex: 1;
  min-width: 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.logo-icon {
  width: 24px;
  height: 24px;
}

.app-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* Center: Search Bar */
.header-center {
  flex: 2;
  display: flex;
  justify-content: center;
}

.search-compact {
  width: 100%;
  max-width: 480px;
  background: var(--bg-color);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem 0.25rem 1rem;
  transition: all 0.2s;
}

.search-compact:focus-within {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.search-compact input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  outline: none;
  padding: 0.4rem 0;
  color: var(--text-main);
}

.btn-icon {
  background: var(--primary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--primary-hover);
}

.play-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Right: Stats (Metadata) */
.header-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.meta-inline {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.stat-pill {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.stat-value {
  color: var(--text-main);
  font-weight: 600;
}

.stat-icon svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  display: block;
}

/* --- 2. Main Scrollable Area --- */
#results-area {
  flex: 1;
  overflow-y: auto;
  /* Internal scroll only */
  padding: 1.5rem;
}

/* Grid Layout - Optimized for Laptops */
.grid {
  display: grid;
  /* Smaller min-width (260px) allows 3-4 columns on laptops */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* --- 3. Card Styling --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: fit-content;
  /* Don't stretch height */
}

.card-header {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Strict Icon Sizing */
.card-header svg,
.icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  color: var(--primary);
}

.data-list {
  list-style: none;
  padding: 0;
}

.copy-item {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
  /* Smaller text for compact fit */
  color: #334155;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}

.copy-item span {
  white-space: normal;
  /* Allows text to wrap to new lines */
  overflow: visible;
  /* Shows all content */
  text-overflow: clip;
  /* Removes the "..." */
  word-break: break-word;
  /* Breaks long URLs so they don't overflow */
  max-width: 90%;
  /* Keeps space for the copy icon */
  line-height: 1.4;
  /* Adds breathing room for multi-line text */
}

.copy-item:last-child {
  border-bottom: none;
}

.copy-item:hover {
  background: #eff6ff;
  color: var(--primary);
}

.copy-icon {
  width: 14px;
  height: 14px;
  opacity: 0;
  color: var(--primary);
  margin-left: 8px;
}

.copy-item:hover .copy-icon {
  opacity: 1;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 4rem;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

/* Error State */
.error-container {
  grid-column: 1 / -1;
  text-align: center;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: var(--radius-md);
  padding: 2rem;
  color: #b91c1c;
}

/* Spinner */
.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  animation: spin 0.8s linear infinite;
  display: none;
  /* Hidden by default */
}

.btn-icon:disabled .spinner {
  display: block;
}

.btn-icon:disabled .play-icon {
  display: none;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Toast */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
}

#toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}