:root {
  --bg: #080d1b;
  --bg-soft: #0d1630;
  --glass: rgba(255, 255, 255, 0.1);
  --glass-strong: rgba(255, 255, 255, 0.16);
  --border: rgba(255, 255, 255, 0.28);
  --text: #f4f7ff;
  --text-dim: #c7d1ec;
  --accent: #ff2e4f;
  --accent-soft: #ff5f79;
  --ok: #5be7b3;
  --warn: #ffca5f;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #1f2c59 0%, var(--bg) 42%, #060912 100%);
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.01em;
  margin: 0;
}

.bg-layer {
  position: fixed;
  inset: -20vmax;
  z-index: -2;
  filter: blur(30px);
  opacity: 0.55;
}

.bg-one {
  background: conic-gradient(from 80deg, #ff3d5b, #0078ff, #15d29b, #ff3d5b);
  animation: spin 20s linear infinite;
}

.bg-two {
  background: radial-gradient(circle at 35% 30%, #f57590 0, rgba(245, 117, 144, 0) 44%),
              radial-gradient(circle at 70% 60%, #4fa7ff 0, rgba(79, 167, 255, 0) 46%);
  z-index: -1;
}

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

.glass {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 20;
  margin: 16px auto 0;
  width: min(1200px, calc(100% - 24px));
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  background: linear-gradient(145deg, var(--accent), var(--accent-soft));
}

.brand h1 {
  font-size: 1rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 540px;
}

.search-shell input,
.magnet-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  background: rgba(9, 13, 28, 0.55);
  color: var(--text);
  font: inherit;
  outline: none;
}

.search-shell input:focus,
.magnet-form input:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(255, 95, 121, 0.28);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 15px;
  font: 700 0.9rem/1 "Manrope", sans-serif;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent), var(--accent-soft));
}

button:hover {
  filter: brightness(1.06);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

main {
  width: min(1200px, calc(100% - 24px));
  margin: 20px auto 40px;
  display: grid;
  gap: 18px;
}

.hero {
  border-radius: var(--radius-lg);
  padding: clamp(18px, 4vw, 30px);
  display: grid;
  gap: 22px;
  grid-template-columns: 1.5fr 1fr;
  min-height: 280px;
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.13);
  margin-bottom: 12px;
}

.hero h2 {
  font-size: clamp(1.5rem, 3.6vw, 2.6rem);
  max-width: 18ch;
}

.hero-sub {
  color: var(--text-dim);
  max-width: 52ch;
}

.hero-stat-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border-radius: var(--radius-md);
  background: rgba(6, 11, 24, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 14px;
}

.stat-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.stat-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h3 {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
}

.content-row {
  border-radius: var(--radius-lg);
  padding: 14px 0 0;
}

.card-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding: 6px 4px 14px;
  scroll-snap-type: x mandatory;
}

.card-row::-webkit-scrollbar {
  height: 8px;
}

.card-row::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

.poster-card {
  scroll-snap-align: start;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: #0a1225;
  border: 1px solid rgba(255, 255, 255, 0.14);
  min-height: 270px;
  transform: translateY(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.poster-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.3);
}

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

.poster-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px;
  background: linear-gradient(to top, rgba(3, 5, 12, 0.95), rgba(3, 5, 12, 0));
}

.poster-overlay h4 {
  font-size: 0.92rem;
  margin: 0 0 3px;
}

.poster-overlay p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.torbox {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.torbox-head {
  margin-bottom: 10px;
}

.torbox-head p {
  margin: 6px 0 0;
  color: var(--text-dim);
}

.magnet-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.message.ok {
  color: var(--ok);
}

.message.warn {
  color: var(--warn);
}

.torbox-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.torbox-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(11, 16, 35, 0.58);
}

.torbox-item h4 {
  font-size: 0.93rem;
  margin: 0 0 4px;
}

.torbox-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.results {
  position: fixed;
  inset: auto 12px 14px;
  z-index: 30;
  width: min(1200px, calc(100% - 24px));
  margin: 0 auto;
  border-radius: var(--radius-lg);
  padding: 14px;
  max-height: 66vh;
  overflow: auto;
}

.results.hidden {
  display: none;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.title-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 100px 1fr;
  min-height: 152px;
}

.title-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #121a31;
}

.title-meta {
  padding: 10px;
  display: grid;
  gap: 3px;
}

.title-meta h4 {
  font-size: 1rem;
}

.title-year,
.title-rating,
.title-plot {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.title-link {
  margin-top: 5px;
  color: #ffd6dd;
  font-size: 0.84rem;
  text-decoration: none;
}

.title-link:hover {
  text-decoration: underline;
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .search-shell {
    max-width: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    top: 8px;
    width: calc(100% - 16px);
    margin-top: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  main {
    width: calc(100% - 16px);
  }

  .results {
    width: calc(100% - 16px);
    inset-inline: 8px;
  }

  .card-row {
    grid-auto-columns: minmax(150px, 1fr);
  }

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

  .title-poster {
    max-height: 190px;
  }
}