/* V111 — light 50-design rail with fitted artwork */
html body.design-ai-page #template-market.template-market {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: #10213b;
  background-color: #f4f9ff !important;
  background-image:
    radial-gradient(circle at 8% 10%, rgba(72, 142, 255, .15), transparent 28%),
    radial-gradient(circle at 92% 72%, rgba(122, 190, 255, .16), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef5ff 54%, #f9fcff 100%) !important;
}

body.design-ai-page .template-market::before,
body.design-ai-page .template-market::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 360px;
  aspect-ratio: 1;
  border: 1px solid rgba(72, 142, 255, .12);
  border-radius: 50%;
  pointer-events: none;
}

body.design-ai-page .template-market::before {
  top: 17%;
  left: -210px;
  box-shadow: 0 0 90px rgba(72, 142, 255, .10);
}

body.design-ai-page .template-market::after {
  right: -230px;
  bottom: 5%;
  box-shadow: 0 0 110px rgba(98, 179, 255, .13);
}

body.design-ai-page .template-market .section-heading h2 {
  color: #10213b;
}

body.design-ai-page .template-market .section-heading > p,
body.design-ai-page .template-market .section-heading p {
  color: #526783;
}

body.design-ai-page .template-market .eyebrow {
  color: #1769da;
}

body.design-ai-page .template-toolbar {
  position: sticky;
  z-index: 12;
  top: 78px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(94, 145, 214, .22);
  border-radius: 14px;
  color: #15345e !important;
  background: rgba(255, 255, 255, .92) !important;
  box-shadow: 0 14px 45px rgba(51, 100, 166, .11);
  backdrop-filter: blur(18px);
}

body.design-ai-page .template-toolbar > span {
  color: #15345e;
}

body.design-ai-page .template-toolbar select {
  min-height: 43px;
  padding: 0 38px 0 13px;
  border: 1px solid rgba(89, 137, 202, .27);
  border-radius: 10px;
  outline: 0;
  color: #17355e !important;
  background-color: #fff !important;
  box-shadow: 0 5px 16px rgba(47, 94, 155, .06);
  cursor: pointer;
}

body.design-ai-page .template-toolbar select:focus-visible {
  border-color: #2f7ee6;
  box-shadow: 0 0 0 3px rgba(47, 126, 230, .14);
}

.template-motion-status {
  min-height: 28px;
  margin: 0 2px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #54708f;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.template-motion-status > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.template-motion-status > span::before {
  content: "";
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, #2f7ee6, #83c8ff);
  box-shadow: 0 0 10px rgba(47, 126, 230, .28);
}

.template-motion-controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.template-motion-arrow,
.template-motion-toggle {
  min-width: 72px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(70, 125, 199, .24);
  border-radius: 9px;
  color: #174b91;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 5px 15px rgba(46, 91, 151, .07);
  font: 800 .58rem Manrope, sans-serif;
  cursor: pointer;
}

.template-motion-arrow {
  min-width: 36px;
  width: 36px;
  padding: 0;
  font-size: .9rem;
}

.template-motion-arrow:hover,
.template-motion-arrow:focus-visible,
.template-motion-toggle:hover,
.template-motion-toggle:focus-visible {
  border-color: rgba(47, 126, 230, .55);
  color: #0d62cf;
  outline: none;
}

.template-rail-viewport {
  position: relative;
  margin: 0 -4px;
  padding: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-snap-type: none;
  scrollbar-width: none;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.template-rail-viewport.is-dragging {
  cursor: grabbing;
}

.template-rail-viewport::-webkit-scrollbar {
  display: none;
}

body.design-ai-page .template-grid {
  position: relative;
  width: max-content;
  display: flex;
  grid-template-columns: none;
  gap: 18px;
  margin: 0;
  padding: 8px 4px 34px;
  overflow: visible;
  animation: none !important;
  transform: none !important;
  will-change: auto;
}

body.design-ai-page .template-grid::after {
  content: "";
  flex: 0 0 1px;
}

body.design-ai-page .template-grid .template-card {
  flex: 0 0 clamp(174px, 16.5vw, 214px);
  min-width: 0;
  scroll-snap-align: start;
  overflow: hidden;
  border: 1px solid rgba(80, 132, 201, .20);
  border-radius: 16px;
  color: #10213b;
  background: rgba(255, 255, 255, .98) !important;
  box-shadow:
    0 18px 45px rgba(45, 88, 147, .12),
    0 3px 10px rgba(45, 88, 147, .05);
  transform: translateZ(0);
}

body.design-ai-page .template-grid .template-card[hidden] {
  display: none !important;
}

body.design-ai-page .template-grid .template-card:hover,
body.design-ai-page .template-grid .template-card.selected {
  border-color: rgba(47, 126, 230, .58);
  box-shadow:
    0 24px 52px rgba(37, 91, 164, .18),
    0 0 0 3px rgba(47, 126, 230, .07);
  transform: translateY(-5px);
}

body.design-ai-page .template-grid .template-card.selected {
  outline: none;
}

body.design-ai-page .template-grid .template-preview {
  aspect-ratio: 9 / 19;
  padding: 0;
  display: block;
  overflow: hidden;
  border-bottom: 1px solid rgba(80, 132, 201, .14);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(231, 241, 255, .94)),
    #edf5ff;
}

body.design-ai-page .template-grid .template-preview img {
  width: 100%;
  height: 100%;
  padding: 0;
  display: block;
  object-fit: cover;
  object-position: center;
  background: #edf5ff;
  transform: scale(1.025);
  transition: transform .45s ease;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

body.design-ai-page .template-grid .template-card:hover .template-preview img,
body.design-ai-page .template-grid .template-card.selected .template-preview img {
  transform: scale(1.055);
}

body.design-ai-page .template-grid .template-preview i,
body.design-ai-page .template-grid .template-preview em,
body.design-ai-page .template-grid .template-preview::after {
  border: 1px solid rgba(255, 255, 255, .58);
  color: #fff;
  background: rgba(12, 36, 68, .72);
  box-shadow: 0 4px 14px rgba(8, 29, 58, .14);
  backdrop-filter: blur(9px);
}

body.design-ai-page .template-grid .template-info {
  min-height: 94px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%) !important;
}

body.design-ai-page .template-grid .template-info b {
  color: #132c50;
  font-size: .74rem;
  line-height: 1.35;
}

body.design-ai-page .template-grid .template-info small {
  margin-top: 5px;
  color: #637892;
  font-size: .54rem;
  line-height: 1.45;
}

body.design-ai-page .template-grid .template-info > strong {
  padding: 6px 7px;
  border: 1px solid rgba(65, 124, 201, .16);
  border-radius: 8px;
  color: #1766c7;
  background: #edf5ff;
  font-size: .54rem;
  line-height: 1;
}

@media (max-width: 760px) {
  body.design-ai-page .template-toolbar {
    top: 68px;
    align-items: stretch;
    gap: 11px;
    padding: 12px;
  }

  body.design-ai-page .template-toolbar > div {
    width: min(100%, 380px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  body.design-ai-page .template-toolbar select {
    width: 100%;
    min-width: 0;
    padding-right: 22px;
    font-size: .62rem;
  }

  .template-motion-status {
    align-items: flex-start;
    margin-bottom: 10px;
    font-size: .59rem;
    line-height: 1.45;
  }

  .template-motion-status > span::before {
    width: 18px;
    flex: 0 0 18px;
    margin-top: .45em;
  }

  .template-motion-toggle {
    min-width: 64px;
    min-height: 32px;
  }

  .template-motion-arrow {
    min-width: 32px;
    width: 32px;
    min-height: 32px;
  }

  .template-rail-viewport {
    margin-right: calc(var(--pad) * -1);
    padding-right: var(--pad);
  }

  body.design-ai-page .template-grid {
    gap: 12px;
    padding-bottom: 27px;
  }

  body.design-ai-page .template-grid .template-card {
    flex-basis: min(56vw, 204px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-rail-viewport { scroll-behavior: auto; }
}
