:root {
  color-scheme: dark;
  --bg: #070b12;
  --card: rgba(17, 24, 39, 0.82);
  --card-solid: #111827;
  --border: rgba(148, 163, 184, 0.16);
  --border-hover: rgba(96, 165, 250, 0.45);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37, 99, 235, 0.22), transparent 70%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(124, 58, 237, 0.16), transparent 65%),
    linear-gradient(180deg, #050811 0%, #090f1d 55%, #060913 100%);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 2rem 1.25rem;
  position: relative;
  overflow-x: hidden;
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.bg-beams {
  position: fixed;
  inset: -20%;
  background:
    conic-gradient(
      from 210deg at 50% 25%,
      transparent 0deg,
      rgba(59, 130, 246, 0.14) 24deg,
      transparent 52deg,
      rgba(168, 85, 247, 0.12) 84deg,
      transparent 120deg
    );
  filter: blur(48px);
  pointer-events: none;
  z-index: 0;
  animation: beamSweep 18s ease-in-out infinite alternate;
}

@keyframes beamSweep {
  0% {
    transform: rotate(-6deg) scale(1);
  }
  100% {
    transform: rotate(6deg) scale(1.06);
  }
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.085) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.085) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 42%, rgba(0, 0, 0, 0.95) 20%, transparent 82%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, rgba(0, 0, 0, 0.95) 20%, transparent 82%);
  pointer-events: none;
  z-index: 0;
}

.bg-noise {
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  filter: blur(115px);
  opacity: 0.38;
  pointer-events: none;
  z-index: 0;
  animation: floatGlow 14s ease-in-out infinite alternate;
}

.bg-glow-1 {
  top: -160px;
  left: -120px;
  background: radial-gradient(circle, #3b82f6, #1d4ed8);
}

.bg-glow-2 {
  bottom: -180px;
  right: -120px;
  background: radial-gradient(circle, #a855f7, #6d28d9);
  animation-delay: -6s;
}

.bg-glow-3 {
  top: 42%;
  left: 55%;
  width: 360px;
  height: 360px;
  opacity: 0.14;
  background: radial-gradient(circle, #06b6d4, #0284c7);
  animation-delay: -11s;
}

@keyframes floatGlow {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(36px, -28px, 0) scale(1.12);
  }
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.card {
  position: relative;
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  padding: 2rem;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(59, 130, 246, 0.12);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.28);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.9rem;
}

.header h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.search-form {
  display: flex;
  gap: 0.7rem;
}

.input-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-form input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.7rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.85);
  color: var(--text);
  font-size: 0.98rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.search-form button,
.btn-primary,
.btn-secondary {
  padding: 0.9rem 1.3rem;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.search-form button,
.btn-primary {
  background: var(--accent);
  color: #fff;
}

.search-form button:hover,
.btn-primary:hover {
  background: var(--accent-hover);
}

.search-form button:active,
.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.98);
}

.search-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
}

.filter-row {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.size-pills {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.size-pill {
  background: rgba(15, 23, 42, 0.85);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.32rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.size-pill:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.size-pill.active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.55);
}

.recent-wrap {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.recent-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.recent-chips {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip {
  background: rgba(30, 41, 59, 0.75);
  color: #cbd5e1;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.72rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--border-hover);
  color: #fff;
}

.status-card {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(9, 13, 22, 0.85);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.2s infinite ease-in-out;
}

.status-dot.done {
  background: var(--success);
  animation: none;
}

.status-dot.error {
  background: var(--error);
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

.status-text {
  font-size: 0.95rem;
  color: var(--muted);
}

.status-text.done {
  color: var(--success);
  font-weight: 600;
}

.status-text.error {
  color: var(--error);
}

.result-actions {
  margin-top: 0.95rem;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.sources-section {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 0.25rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.section-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.source-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.1rem;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.source-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  background: rgba(23, 32, 51, 0.92);
}

.source-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.source-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.tag-tamil {
  color: #f9a8d4;
  background: rgba(236, 72, 153, 0.15);
}

.tag-sub {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.18);
}

.tag-en {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.16);
}

.source-arrow {
  color: var(--muted);
  font-size: 0.95rem;
}

.source-card h3 {
  margin: 0.2rem 0 0;
  font-size: 0.98rem;
}

.source-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .card {
    padding: 1.35rem;
  }

  .search-form {
    flex-direction: column;
  }

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