:root {
  --bg: #2b1e3e;
  --bg-deep: #1c152a;
  --ink: #e6e6fa;
  --muted: #b9b1d8;
  --accent: #a490c2;
  --accent-strong: #4a4e8f;
  --line: rgba(230, 230, 250, 0.2);
  --tile-glow: rgba(164, 144, 194, 0.35);
  --shadow: 0 30px 80px rgba(10, 7, 20, 0.55);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "FreeSans", "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, rgba(74, 78, 143, 0.35), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(164, 144, 194, 0.25), transparent 50%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
}

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 6rem 6vw 5rem;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(43, 30, 62, 0.95) 30%, rgba(28, 21, 42, 0.4) 100%);
  z-index: 1;
}

.hero-media {
  position: absolute;
  inset: -10% 0 0;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 120px;
  gap: 16px;
  padding: 5rem 6vw;
  opacity: 0.7;
  z-index: 0;
  transform: translateY(0);
  transition: transform 0.2s ease-out;
}

.hero-media .tile {
  position: relative;
  border-radius: 18px;
  background-size: cover;
  background-position: center;
  filter: saturate(1.1) contrast(1.05);
  box-shadow: inset 0 0 0 1px rgba(230, 230, 250, 0.15);
}

.hero-content {
  position: relative;
  max-width: 640px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-sentinel {
  height: 1px;
  width: 100%;
}

.brand {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.78rem;
  color: var(--accent);
}

h1 {
  font-size: clamp(2.8rem, 4vw, 4.4rem);
  line-height: 1.05;
  margin: 0;
}

.lead {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(28, 21, 42, 0.8);
  box-shadow: var(--shadow);
}

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 1rem;
  outline: none;
}

.search-bar input::placeholder {
  color: rgba(230, 230, 250, 0.45);
}

.meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.filters {
  padding: 1.5rem 6vw 0;
  position: relative;
  z-index: 5;
  background: linear-gradient(180deg, rgba(43, 30, 62, 0.95), rgba(43, 30, 62, 0.7) 70%, transparent);
  backdrop-filter: blur(12px);
}

.filters-fixed .filters {
  height: 96px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 6vw;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
  box-shadow: 0 18px 40px rgba(12, 8, 22, 0.45);
  overflow: hidden;
  animation: filtersPin 0.35s ease forwards;
}

.filters-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.filters-fixed .filters-inner {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  grid-template-rows: repeat(2, auto);
  gap: 0.6rem 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: calc(96px - 1.2rem);
  padding-bottom: 0.2rem;
  animation: filtersClamp 0.35s ease forwards;
}

@keyframes filtersPin {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes filtersClamp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filters-spacer {
  height: 0;
}

.tag {
  border: 1px solid var(--line);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s ease;
  background: rgba(28, 21, 42, 0.6);
}

.tag.active {
  color: var(--bg-deep);
  background: var(--accent);
  border-color: transparent;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.8rem;
  padding: 3rem 6vw 5rem;
}

.tile {
  position: relative;
  min-height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: rgba(28, 21, 42, 0.7);
  box-shadow: var(--shadow);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.35s ease, box-shadow 0.35s ease, opacity 0.35s ease;
}

.tile.reveal {
  transform: translateY(0);
  opacity: 1;
}

.tile-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(1.05);
  transition: transform 0.4s ease, filter 0.4s ease;
}

.tile:hover .tile-image {
  transform: scale(1.04);
  filter: brightness(0.9) saturate(1.2);
}

.tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 13, 28, 0.2), rgba(18, 13, 28, 0.85));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.4rem;
}

.tile-title {
  font-size: 1.2rem;
  margin: 0 0 0.6rem;
}

.tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.3s ease;
}

.tile:hover .tile-tags {
  opacity: 1;
  transform: translateY(0);
}

.tile-tags span {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(164, 144, 194, 0.25);
  border: 1px solid rgba(164, 144, 194, 0.5);
}

.footer {
  padding: 3rem 6vw 5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.detail {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  color: var(--ink);
  overflow-y: auto;
  z-index: 20;
}

.detail-nav {
  position: sticky;
  top: 0;
  padding: 1.5rem 6vw;
  background: rgba(28, 21, 42, 0.9);
  backdrop-filter: blur(12px);
  z-index: 2;
}

.detail-back {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 1.4rem;
  cursor: pointer;
}

.detail-hero {
  width: 100%;
  max-height: 60vh;
  overflow: hidden;
  background: rgba(18, 13, 28, 0.6);
}

.detail-hero img {
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.detail-body {
  padding: 3rem 6vw 6rem;
  display: grid;
  gap: 2.5rem;
}

.detail-header h2 {
  font-size: clamp(2rem, 3vw, 3rem);
  margin: 0 0 1rem;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.detail-tags span {
  border: 1px solid var(--line);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
}

.detail-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

.detail-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.detail-copy {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-copy.copied {
  background: var(--accent);
  color: var(--bg-deep);
  border-color: transparent;
}

.detail-prompt pre {
  background: rgba(18, 13, 28, 0.7);
  border-radius: 16px;
  padding: 1.5rem;
  white-space: pre-wrap;
  font-family: "FreeSans", "Space Grotesk", sans-serif;
  color: var(--ink);
  border: 1px solid var(--line);
}

.detail-meta a {
  color: var(--accent);
  text-decoration: none;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.detail-gallery img {
  width: 100%;
  border-radius: 16px;
  height: 220px;
  object-fit: cover;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.detail-gallery img:hover {
  transform: scale(1.02);
  box-shadow: 0 18px 40px rgba(12, 8, 22, 0.45);
}

body.detail-open {
  overflow: hidden;
}

.hero-content > * {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s ease forwards;
}

.hero-content > *:nth-child(1) { animation-delay: 0.1s; }
.hero-content > *:nth-child(2) { animation-delay: 0.2s; }
.hero-content > *:nth-child(3) { animation-delay: 0.3s; }
.hero-content > *:nth-child(4) { animation-delay: 0.4s; }

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    padding: 5rem 7vw 4rem;
  }
  .hero-media {
    grid-auto-rows: 90px;
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: auto;
    padding-top: 6rem;
  }
  .search-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .tile {
    min-height: 260px;
  }
}
