/* Final layout for creator template galleries. Loaded after styles.css on purpose. */
body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) {
  width: min(540px, calc(100vw - 24px)) !important;
  max-width: min(540px, calc(100vw - 24px)) !important;
  padding: 14px 16px 12px !important;
  border-radius: 16px !important;
}

body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) .template-title-row {
  min-height: 42px !important;
  padding: 0 0 12px !important;
  border-bottom: 1px solid color-mix(in srgb, var(--creator-dialog-line) 78%, transparent) !important;
  grid-template-columns: 40px minmax(0, 1fr) 40px !important;
}

body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) .template-title-row h3 {
  font-size: 18px !important;
  font-weight: 900 !important;
  line-height: 1.1 !important;
  text-align: center !important;
}

body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) .template-title-row .icon-button {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  border-radius: 10px !important;
}

body #app > .app.creator-app .narration-template-sheet .narration-template-layout,
body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) .template-gallery {
  max-height: min(68dvh, 690px) !important;
  padding: 14px 0 12px !important;
  overflow: auto !important;
  scrollbar-width: none !important;
}

body #app > .app.creator-app .narration-template-sheet .narration-template-layout::-webkit-scrollbar,
body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) .template-gallery::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

body #app > .app.creator-app .narration-template-grid,
body #app > .app.creator-app .global-style-gallery-sheet .template-gallery {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
  align-items: start !important;
}

body #app > .app.creator-app .narration-template-card,
body #app > .app.creator-app .global-style-template-card {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 14px !important;
  border: 1px solid color-mix(in srgb, var(--template-accent, var(--theme-primary, #c56cff)) 38%, rgba(255, 255, 255, .08)) !important;
  background: #08050c !important;
  box-shadow: none !important;
  text-align: left !important;
}

body #app > .app.creator-app .narration-template-card.active,
body #app > .app.creator-app .global-style-template-card.active {
  border-color: var(--template-accent, var(--creator-dialog-accent)) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--template-accent, var(--creator-dialog-accent)) 46%, transparent) !important;
}

body #app > .app.creator-app .narration-template-card {
  position: relative !important;
  display: block !important;
  height: 300px !important;
}

body #app > .app.creator-app .narration-template-card::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  inset: auto 0 0 !important;
  z-index: 2 !important;
  height: 48% !important;
  background: linear-gradient(180deg, rgba(4, 2, 8, 0) 0%, rgba(4, 2, 8, .72) 42%, rgba(4, 2, 8, .98) 100%) !important;
  pointer-events: none !important;
}

body #app > .app.creator-app .narration-template-card::after,
body #app > .app.creator-app .global-style-template-card::before,
body #app > .app.creator-app .global-style-template-card::after {
  content: none !important;
  display: none !important;
}

body #app > .app.creator-app .narration-template-card .narration-template-preview {
  position: absolute !important;
  inset: 0 !important;
  z-index: 1 !important;
  grid-row: auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: inherit !important;
  overflow: hidden !important;
  background: #08050c !important;
}

body #app > .app.creator-app .narration-template-preview.has-thumbnail img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: top center !important;
}

body #app > .app.creator-app .narration-template-preview.is-card:not(.has-thumbnail) .role-detail-narration-scope {
  position: absolute !important;
  top: 0 !important;
  left: 50% !important;
  width: 430px !important;
  min-width: 430px !important;
  max-width: 430px !important;
  transform: translateX(-50%) scale(.54) !important;
  transform-origin: top center !important;
}

body #app > .app.creator-app .narration-template-card strong,
body #app > .app.creator-app .narration-template-card span:not(.template-selected-mark) {
  position: absolute !important;
  left: 12px !important;
  right: 12px !important;
  z-index: 3 !important;
  display: -webkit-box !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  color: #fff8dd !important;
  letter-spacing: 0 !important;
  text-align: left !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .72) !important;
  -webkit-box-orient: vertical !important;
}

body #app > .app.creator-app .narration-template-card strong {
  bottom: 48px !important;
  font-size: 16px !important;
  font-weight: 900 !important;
  line-height: 1.24 !important;
  -webkit-line-clamp: 2 !important;
}

body #app > .app.creator-app .narration-template-card span:not(.template-selected-mark) {
  bottom: 14px !important;
  color: rgba(255, 248, 221, .86) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.34 !important;
  -webkit-line-clamp: 2 !important;
}

body #app > .app.creator-app .global-style-template-card {
  position: relative !important;
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto auto !important;
  height: 284px !important;
  background: #08050c !important;
}

body #app > .app.creator-app .global-style-card-preview {
  position: relative !important;
  inset: auto !important;
  grid-row: 1 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border: 0 !important;
  border-radius: 13px 13px 0 0 !important;
  overflow: hidden !important;
  background-color: #08050c !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
  background-position: top center !important;
}

body #app > .app.creator-app .global-style-card-preview.has-image {
  background-image: var(--template-preview-image) !important;
}

body #app > .app.creator-app .global-style-card-preview.has-image::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  inset: auto 0 0 !important;
  height: 34% !important;
  background: linear-gradient(180deg, rgba(4, 2, 8, 0), rgba(4, 2, 8, .22)) !important;
  pointer-events: none !important;
}

body #app > .app.creator-app .global-style-card-preview.has-image .global-preview-message,
body #app > .app.creator-app .global-style-card-preview.has-image .global-preview-avatar {
  display: none !important;
}

body #app > .app.creator-app .global-style-template-card strong,
body #app > .app.creator-app .global-style-template-card span:not(.template-selected-mark) {
  position: relative !important;
  inset: auto !important;
  z-index: 2 !important;
  display: -webkit-box !important;
  min-height: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  color: #fff !important;
  letter-spacing: 0 !important;
  text-align: left !important;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .55) !important;
  -webkit-box-orient: vertical !important;
}

body #app > .app.creator-app .global-style-template-card strong {
  grid-row: 2 !important;
  padding: 11px 12px 0 !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  line-height: 1.28 !important;
  -webkit-line-clamp: 2 !important;
}

body #app > .app.creator-app .global-style-template-card span:not(.template-selected-mark) {
  grid-row: 3 !important;
  padding: 4px 12px 12px !important;
  color: rgba(255, 255, 255, .86) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.34 !important;
  -webkit-line-clamp: 2 !important;
}

body #app > .app.creator-app .template-selected-mark {
  top: 8px !important;
  right: 8px !important;
  z-index: 5 !important;
  width: 27px !important;
  min-width: 27px !important;
  height: 27px !important;
  min-height: 27px !important;
  border-radius: 50% !important;
  border: 2px solid rgba(255, 255, 255, .82) !important;
  background: color-mix(in srgb, var(--template-accent, var(--creator-dialog-accent)) 70%, #241332 30%) !important;
  color: #fff !important;
  font-size: 16px !important;
  line-height: 1 !important;
}

body #app > .app.creator-app .template-bottom-actions {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 6 !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px !important;
  min-height: 68px !important;
  margin: 0 !important;
  padding: 12px 0 0 !important;
  border-top: 1px solid color-mix(in srgb, var(--creator-dialog-line) 72%, transparent) !important;
  background:
    linear-gradient(180deg, transparent 0%, var(--creator-dialog-bg) 26%),
    var(--creator-dialog-bg) !important;
}

body #app > .app.creator-app .template-bottom-actions .secondary-button,
body #app > .app.creator-app .template-bottom-actions .template-use-button {
  min-height: 46px !important;
  border-radius: 999px !important;
  font-size: 15px !important;
  font-weight: 900 !important;
  letter-spacing: 0 !important;
}

@media (max-width: 720px) {
  body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) {
    width: min(430px, 100vw) !important;
    max-width: min(430px, 100vw) !important;
    padding: 18px 18px 12px !important;
    border-radius: 16px 16px 0 0 !important;
  }

  body #app > .app.creator-app .narration-template-card {
    height: 270px !important;
  }

  body #app > .app.creator-app .global-style-template-card {
    height: 252px !important;
  }

  body #app > .app.creator-app .narration-template-card strong {
    bottom: 46px !important;
    font-size: 14px !important;
  }

  body #app > .app.creator-app .narration-template-card span:not(.template-selected-mark),
  body #app > .app.creator-app .global-style-template-card span:not(.template-selected-mark) {
    font-size: 11.5px !important;
  }

  body #app > .app.creator-app .global-style-template-card strong {
    font-size: 13px !important;
  }
}

@media (max-width: 380px) {
  body #app > .app.creator-app .template-sheet:is(.narration-template-sheet, .gallery-sheet) {
    padding-inline: 14px !important;
  }

  body #app > .app.creator-app .narration-template-grid,
  body #app > .app.creator-app .global-style-gallery-sheet .template-gallery {
    gap: 10px !important;
  }

  body #app > .app.creator-app .narration-template-card {
    height: 238px !important;
  }

  body #app > .app.creator-app .global-style-template-card {
    height: 232px !important;
  }

  body #app > .app.creator-app .narration-template-card strong,
  body #app > .app.creator-app .global-style-template-card strong {
    font-size: 12.5px !important;
  }

  body #app > .app.creator-app .narration-template-card span:not(.template-selected-mark),
  body #app > .app.creator-app .global-style-template-card span:not(.template-selected-mark) {
    font-size: 10.5px !important;
    -webkit-line-clamp: 2 !important;
  }
}
