:root {
  color-scheme: light;
  --bg: #fff7fb;
  --panel: #ffffff;
  --ink: #211724;
  --muted: #756a78;
  --line: #efddea;
  --pink: #fb3f92;
  --coral: #ff6a45;
  --mint: #20ca83;
  --blue: #348ef7;
  --violet: #7d5cff;
  --shadow: 0 18px 42px rgba(62, 34, 72, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 106, 69, 0.1) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(225deg, rgba(52, 142, 247, 0.08) 25%, transparent 25%) 0 0 / 28px 28px,
    radial-gradient(circle at 10% 0%, rgba(251, 63, 146, 0.28), transparent 32%),
    radial-gradient(circle at 98% 4%, rgba(52, 142, 247, 0.22), transparent 30%),
    linear-gradient(180deg, #fffdfd 0%, #f7f3f7 42%, #f3f6f8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 14px 16px 12px;
  background: rgba(255, 248, 252, 0.94);
  border-bottom: 1px solid rgba(238, 224, 239, 0.75);
  backdrop-filter: blur(18px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 1120px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--pink);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  max-width: 760px;
  font-size: clamp(24px, 6.8vw, 40px);
  line-height: 1.02;
}

.icon-action {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe6ef, #fff6fa);
  box-shadow: 0 0 0 4px rgba(255, 104, 75, 0.12), 0 12px 24px rgba(255, 74, 150, 0.2);
}

.icon-action img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 50%;
}

.search-panel {
  max-width: 1120px;
  margin: 10px auto 0;
}

.search-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

#searchInput {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
  box-shadow: 0 8px 18px rgba(68, 43, 81, 0.08);
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 12px 14px 32px;
}

.hero-section {
  margin-bottom: 16px;
}

.hero-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 42%);
  gap: 12px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}

.hero-strip::-webkit-scrollbar {
  display: none;
}

.hero-tile {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border-radius: 18px;
  background: #201724;
  box-shadow: var(--shadow);
}

.hero-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
  transform: scale(1.02);
}

.hero-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 18%, rgba(28, 13, 30, 0.78) 100%);
}

.hero-tile span {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  text-align: left;
}

.ad-slot {
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #9b8fa1;
  font-size: 12px;
  text-align: center;
  overflow: hidden;
}

.ad-hero {
  min-height: 0;
  margin: 10px 0 16px;
}

.ad-feed {
  grid-column: 1 / -1;
  min-height: 0;
  margin: 12px 0;
}

.ad-footer {
  min-height: 0;
  margin-bottom: 12px;
}

.ad-slot:has(.adsbygoogle[data-ad-status="unfilled"]),
.ad-slot.ad-empty {
  display: none;
}

.ad-hero .adsbygoogle {
  max-width: 320px;
  max-height: 100px;
  overflow: hidden;
}

.ad-footer .adsbygoogle {
  max-width: 320px;
  max-height: 50px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.section-heading p {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.category-chips {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 1px 14px;
  scrollbar-width: none;
}

.category-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  border-radius: 999px;
  padding: 0 16px;
  color: #372c3c;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 14px;
  font-weight: 800;
}

.chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--coral));
  box-shadow: 0 10px 22px rgba(255, 74, 150, 0.28);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 2px 0 16px;
  padding: 5px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tool-button {
  min-height: 38px;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tool-button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 18px rgba(68, 43, 81, 0.1);
}

.template-grid {
  column-count: 2;
  column-gap: 10px;
}

.template-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 10px;
  break-inside: avoid;
  overflow: hidden;
  border: 1px solid rgba(38, 32, 40, 0.08);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(36, 28, 40, 0.1);
}

.template-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 3 / 4);
  border: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 0, 0, 0.04), transparent 22%),
    linear-gradient(120deg, #ffffff, #f4f2f0);
}

.template-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 7px;
}

.template-body {
  display: grid;
  gap: 7px;
  padding: 9px;
}

.template-body h3 {
  min-height: 34px;
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.25;
}

.template-tag {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  color: #bd2b6b;
  background: #fff0f6;
  font-size: 11px;
  font-weight: 900;
}

.template-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.download-button {
  width: 100%;
  min-height: 38px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--coral));
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(255, 104, 75, 0.24);
}

.load-more {
  display: block;
  width: min(360px, 100%);
  min-height: 48px;
  margin: 22px auto 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--mint), var(--blue));
  font-weight: 900;
  box-shadow: var(--shadow);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
}

.modal-shell.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 25, 37, 0.48);
}

.modal-card {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  transform: translateX(-50%);
  border-radius: 24px 24px 0 0;
  background: #fff;
  box-shadow: 0 -18px 42px rgba(32, 25, 37, 0.2);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  font-size: 24px;
  line-height: 1;
}

.modal-preview {
  display: grid;
  place-items: center;
  min-height: 320px;
  background:
    linear-gradient(90deg, rgba(238, 232, 238, 0.8) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(0deg, rgba(238, 232, 238, 0.8) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, #fff7fb, #f4fbff);
}

.modal-preview img {
  width: min(82%, 330px);
  max-height: 380px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(68, 43, 81, 0.16);
}

.modal-copy {
  padding: 18px 18px 24px;
}

.modal-category {
  margin-bottom: 4px;
  color: var(--pink);
  font-size: 13px;
  font-weight: 900;
}

.modal-copy h2 {
  margin-bottom: 6px;
}

.modal-copy p {
  color: var(--muted);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--coral));
}

.secondary-button {
  color: var(--ink);
  background: #fff0f6;
}

footer {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 16px 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 22px 0;
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.skeleton .template-preview,
.skeleton h3,
.skeleton .template-meta span {
  color: transparent;
  background: linear-gradient(90deg, #f6edf4, #fff, #f6edf4);
  background-size: 220% 100%;
  animation: shimmer 1.1s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

@media (min-width: 680px) {
  main {
    padding: 16px 16px 34px;
  }

  h1 {
    font-size: clamp(34px, 5vw, 48px);
  }

  .icon-action {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
  }

  .icon-action img {
    width: 39px;
    height: 39px;
  }

  .hero-strip {
    grid-auto-columns: minmax(190px, 28%);
  }

  .hero-tile {
    min-height: 132px;
  }

  .template-grid {
    column-count: 3;
    column-gap: 13px;
  }

  .template-card {
    margin-bottom: 13px;
  }

  .template-body {
    gap: 8px;
    padding: 11px;
  }

  .download-button {
    min-height: 40px;
  }
}

@media (min-width: 980px) {
  .app-header {
    padding-top: 24px;
  }

  .template-grid {
    column-count: 5;
    column-gap: 16px;
  }

  .modal-card {
    top: 50%;
    bottom: auto;
    display: grid;
    grid-template-columns: 52% 48%;
    max-height: 760px;
    transform: translate(-50%, -50%);
    border-radius: 22px;
  }
}
